Skip to content

Commit

Permalink
Added gettext (.po) language support (#3369)
Browse files Browse the repository at this point in the history
  • Loading branch information
RunDevelopment authored Mar 21, 2022
1 parent d17e376 commit dfef9b6
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@
"title": "GEDCOM",
"owner": "Golmote"
},
"gettext": {
"title": "gettext",
"alias": "po",
"owner": "RunDevelopment"
},
"gherkin": {
"title": "Gherkin",
"owner": "hason"
Expand Down
43 changes: 43 additions & 0 deletions components/prism-gettext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Prism.languages.gettext = {
'comment': [
{
pattern: /# .*/,
greedy: true,
alias: 'translator-comment'
},
{
pattern: /#\..*/,
greedy: true,
alias: 'extracted-comment'
},
{
pattern: /#:.*/,
greedy: true,
alias: 'reference-comment'
},
{
pattern: /#,.*/,
greedy: true,
alias: 'flag-comment'
},
{
pattern: /#\|.*/,
greedy: true,
alias: 'previously-untranslated-comment'
},
{
pattern: /#.*/,
greedy: true
},
],
'string': {
pattern: /(^|[^\\])"(?:[^"\\]|\\.)*"/,
lookbehind: true,
greedy: true
},
'keyword': /^msg(?:ctxt|id|id_plural|str)\b/m,
'number': /\b\d+\b/,
'punctuation': /[\[\]]/
};

Prism.languages.po = Prism.languages.gettext;
1 change: 1 addition & 0 deletions components/prism-gettext.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions examples/prism-gettext.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<h2>Full example</h2>
<pre><code># Source: https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html
#: lib/error.c:116
msgid "Unknown system error"
msgstr "Error desconegut del sistema"
</code></pre>
1 change: 1 addition & 0 deletions plugins/autoloader/prism-autoloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
"xlsx": "excel-formula",
"xls": "excel-formula",
"gamemakerlanguage": "gml",
"po": "gettext",
"gni": "gn",
"go-mod": "go-module",
"hbs": "handlebars",
Expand Down
2 changes: 1 addition & 1 deletion plugins/autoloader/prism-autoloader.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions plugins/show-language/prism-show-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
"gcode": "G-code",
"gdscript": "GDScript",
"gedcom": "GEDCOM",
"gettext": "gettext",
"po": "gettext",
"glsl": "GLSL",
"gn": "GN",
"gni": "GN",
Expand Down
Loading

0 comments on commit dfef9b6

Please sign in to comment.