Skip to content

Commit 3e34416

Browse files
authored
Merge pull request #50 from Crizz0/issue/49
Add lang keys for syntax languages
2 parents c73682c + 5463fb7 commit 3e34416

File tree

4 files changed

+47
-87
lines changed

4 files changed

+47
-87
lines changed

config/services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
arguments:
1111
- '%phpbbde.pastebin.geshilangs%'
1212
- '%core.php_ext%'
13+
- '@language'
1314
phpbbde.pastebin.functions.pastebin:
1415
class: phpbbde\pastebin\functions\pastebin
1516
arguments:

functions/utility.php

Lines changed: 24 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,23 @@ class utility
2727
/** @var string */
2828
protected $php_ext;
2929

30+
/* @var \phpbb\language\language */
31+
protected $language;
32+
3033
/**
3134
* Constructor
3235
* @param string $php_ext
36+
* @param \phpbb\language\language $language
3337
*/
3438
function __construct(
3539
$geshi_dir,
36-
$php_ext)
40+
$php_ext,
41+
\phpbb\language\language $language)
3742
{
3843
$this->geshi_dir = $geshi_dir;
3944
$this->geshi_list = $this->geshi_list();
4045
$this->php_ext = $php_ext;
46+
$this->language = $language;
4147
}
4248

4349

@@ -81,91 +87,21 @@ function geshi_list()
8187
*/
8288
function highlight_select($default = 'text')
8389
{
84-
// Programming languages
85-
// these are used by geshi
90+
/** Programming languages used by geshi
91+
* Check \phpbbde\pastebin\vendor\easybook\geshi\geshi for more languages
92+
* Add them to the array $programming_langs
93+
* Don't forget to add fitting language variables to \phpbbde\pastebin\language\<iso>\pastebin.php as well
94+
*/
8695
$programming_langs = array(
87-
'text' => 'Text',
88-
'php' => 'PHP',
89-
'sql' => 'SQL',
90-
'html4strict' => 'HTML',
91-
'css' => 'CSS',
92-
'javascript' => 'Javascript',
93-
'xml' => 'XML',
94-
'diff' => 'Diff',
95-
'robots' => 'robots.txt',
96-
97-
/**
98-
* Wenn eine weitere Sprache aktiviert werden soll, muss die Datei in den includes/geshi/ Ordner
99-
* kopiert werden, und der Eintrag der Sprachdatei wieder nach aktiviert werden.
100-
*/
101-
102-
/*
103-
'actionscript' => 'ActionScript',
104-
'ada' => 'Ada',
105-
'apache' => 'Apache',
106-
'applescript' => 'AppleScript',
107-
'asm' => 'x86 Assembler',
108-
'autoit' => 'AutoIt',
109-
'bash' => 'Bash',
110-
'blitzbasic' => 'BlitzBasic',
111-
'bnf' => 'BNF',
112-
'c_mac' => 'C (Mac)',
113-
'caddcl' => 'CAD DCL',
114-
'cadlisp' => 'CAD Lisp',
115-
'cfdg' => 'CFDG',
116-
'cfm' => 'ColdFusion',
117-
'cpp-qt' => 'C++ (QT)',
118-
'css-gen.cfg' => 'C#',
119-
'c_mac' => 'C (Mac)',
120-
'd' => 'D',
121-
'delphi' => 'Delphi',
122-
'div' => 'DIV',
123-
'dos' => 'DOS',
124-
'eiffel' => 'Eiffel',
125-
'fortran' => 'Fortran',
126-
'freebasic' => 'FreeBasic',
127-
'gml' => 'GML',
128-
'groovy' => 'Groovy',
129-
'idl' => 'Uno Idl',
130-
'ini' => 'INI',
131-
'inno' => 'Inno',
132-
'io' => 'Io',
133-
'java5' => 'Java(TM) 2 Platform Standard Edition 5.0',
134-
'latex' => 'LaTeX',
135-
'lisp' => 'Lisp',
136-
'lua' => 'Lua',
137-
'matlab' => 'Matlab M',
138-
'mirc' => 'mIRC Scripting',
139-
'mpasm' => 'Microchip Assembler',
140-
'mysql' => 'MySQL',
141-
'nsis' => 'NSIS',
142-
'objc' => 'Objective C',
143-
'ocaml-brief' => 'OCaml',
144-
'ocaml' => 'OCaml',
145-
'oobas' => 'OpenOffice.org Basic',
146-
'oracle8' => 'Oracle 8 SQL',
147-
'pascal' => 'Pascal',
148-
'php-brief' => 'PHP (brief)',
149-
'ruby' => 'Ruby',
150-
'sas' => 'SAS',
151-
'scheme' => 'Scheme',
152-
'sdlbasic' => 'sdlBasic',
153-
'smalltalk' => 'Smalltalk',
154-
'tcl' => 'TCL',
155-
'thinbasic' => 'thinBasic',
156-
'tsql' => 'T-SQL',
157-
'plsql' => 'PL/SQL',
158-
'python' => 'Python',
159-
'qbasic' => 'QBasic/QuickBASIC',
160-
'rails' => 'Rails',
161-
'reg' => 'Microsoft Registry',
162-
'vbnet' => 'vb.net',
163-
'vhdl' => 'VHDL',
164-
'visualfoxpro' => 'Visual Fox Pro',
165-
'winbatch' => 'Winbatch',
166-
'xpp' => 'X++',
167-
'z80' => 'ZiLOG Z80 Assembler',
168-
*/
96+
'text',
97+
'php',
98+
'sql',
99+
'html5',
100+
'css',
101+
'javascript',
102+
'xml',
103+
'diff',
104+
'robots',
169105
);
170106

171107
if (!in_array($default, $this->geshi_list))
@@ -174,11 +110,12 @@ function highlight_select($default = 'text')
174110
}
175111

176112
$output = '';
177-
foreach ($programming_langs as $code => $name)
113+
$lang_prefix = 'PASTEBIN_LANGS_';
114+
foreach ($programming_langs as $code)
178115
{
179116
if (in_array($code, $this->geshi_list))
180117
{
181-
$output .= '<option' . (($default == $code) ? ' selected="selected"' : '') . ' value="' . htmlentities($code, ENT_QUOTES) . '">' . $name . '</option>';
118+
$output .= '<option' . (($default == $code) ? ' selected="selected"' : '') . ' value="' . htmlentities($code, ENT_QUOTES) . '">' . $this->language->lang($lang_prefix . strtoupper($code)) . '</option>';
182119
}
183120
}
184121

language/de/pastebin.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,15 @@
101101
'PASTEBIN_SNIPPET_PRUNABLE' => 'Eintrag prunable - automatisch löschbar',
102102
'PASTEBIN_SNIPPET_PRUNABLE_EXPLAIN' => 'Wenn diese Option deaktiviert ist, wird der Eintrag nicht in die monatlich automatisch zu löschenden Einträge aufgenommen.',
103103
'PASTEBIN_SNIPPET_SUBMITTED' => 'Dein Eintrag wurde erfolgreich erstellt.',
104+
105+
// Language keys for Syntax highlighting dropdown
106+
'PASTEBIN_LANGS_TEXT' => 'Text',
107+
'PASTEBIN_LANGS_PHP' => 'PHP',
108+
'PASTEBIN_LANGS_SQL' => 'SQL',
109+
'PASTEBIN_LANGS_HTML5' => 'HTML',
110+
'PASTEBIN_LANGS_CSS' => 'CSS',
111+
'PASTEBIN_LANGS_JAVASCRIPT' => 'JavaScript',
112+
'PASTEBIN_LANGS_XML' => 'XML',
113+
'PASTEBIN_LANGS_DIFF' => 'diff',
114+
'PASTEBIN_LANGS_ROBOTS' => 'Robots.txt',
104115
));

language/en/pastebin.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,15 @@
100100
'PASTEBIN_SNIPPET_PRUNABLE' => 'Entry prunable',
101101
'PASTEBIN_SNIPPET_PRUNABLE_EXPLAIN' => 'If this option is disabled, the entry will not be entered in the monthly list of prunable entries.',
102102
'PASTEBIN_SNIPPET_SUBMITTED' => 'Your entry was sucessfully created.',
103+
104+
// Language keys for Syntax highlighting dropdown
105+
'PASTEBIN_LANGS_TEXT' => 'Text',
106+
'PASTEBIN_LANGS_PHP' => 'PHP',
107+
'PASTEBIN_LANGS_SQL' => 'SQL',
108+
'PASTEBIN_LANGS_HTML5' => 'HTML',
109+
'PASTEBIN_LANGS_CSS' => 'CSS',
110+
'PASTEBIN_LANGS_JAVASCRIPT' => 'JavaScript',
111+
'PASTEBIN_LANGS_XML' => 'XML',
112+
'PASTEBIN_LANGS_DIFF' => 'diff',
113+
'PASTEBIN_LANGS_ROBOTS' => 'Robots.txt',
103114
));

0 commit comments

Comments
 (0)