Skip to content

Commit

Permalink
add multi-language support for app
Browse files Browse the repository at this point in the history
  • Loading branch information
ACTom committed Oct 18, 2018
1 parent fc40d22 commit d966a16
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ source_dir=$(build_dir)/source
sign_dir=$(build_dir)/sign
package_name=$(app_name)
cert_dir=$(CURDIR)/../../key
version+=0.0.5
version+=0.0.6

all: appstore

Expand Down
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<name>Mind Map</name>
<summary>A Mind map editor</summary>
<description><![CDATA[This application enables Nextcloud users to open, save and edit mind map files in the web browser. If enabled, an entry in the New button at the top of the web browser the Mindmap file entry appears. When clicked, a new mindmap file opens in the browser and the file can be saved into the current Nextcloud directory.]]></description>
<version>0.0.5</version>
<version>0.0.6</version>
<licence>agpl</licence>
<author mail="i@actom.me" homepage="https://actom.me">Jingtao Yan</author>
<namespace>Files_MindMap</namespace>
Expand Down
8 changes: 4 additions & 4 deletions js/mindmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ var FilesMindMap = {
}
})
.done(function(){
success('内容已保存')
success(t('files_mindmap', 'File Saved'))
self._changed = false;
}).fail(function(jqXHR){
var message = '保存失败';
var message = t('files_mindmap', 'Save failed');
try{
message = JSON.parse(jqXHR.responseText).message;
}catch(e){
Expand Down Expand Up @@ -184,8 +184,8 @@ FilesMindMap.NewFileMenuPlugin = {
// register the new menu entry
menu.addMenuEntry({
id: 'mindmapfile',
displayName: '新建思维导图文件',
templateName: '新建思维导图.km',
displayName: t('files_mindmap', 'New mind map file'),
templateName: t('files_mindmap', 'New mind map.km'),
iconClass: 'icon-link',
fileType: 'mindmap',
actionHandler: function(name) {
Expand Down
12 changes: 8 additions & 4 deletions js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ function redirectIfNotDisplayedInFrame () {
redirectIfNotDisplayedInFrame();

(function() {
var t = function(msg) {
return window.parent.t('files_mindmap', msg);
};

var MindMap = {
_changed: false,
_saveTimer: null,
Expand Down Expand Up @@ -88,7 +92,7 @@ redirectIfNotDisplayedInFrame();
save: function() {
var self = this;
if (self._changed) {
self.setStatusMessage('正在保存...');
self.setStatusMessage(t('Saving...'));
var data = JSON.stringify(minder.exportJson());
window.parent.OCA.FilesMindMap.save(data, function(msg){
self.setStatusMessage(msg);
Expand All @@ -104,7 +108,7 @@ redirectIfNotDisplayedInFrame();
{"data":
{"id":"bopmq"+String(Math.floor(Math.random() * 9e15)).substr(0, 7),
"created":(new Date()).getTime(),
"text":"中心主题"
"text":t('Main Topic')
},
"children":[]
},
Expand All @@ -118,15 +122,15 @@ redirectIfNotDisplayedInFrame();
try {
obj = JSON.parse(data);
} catch (e){
alert('此文件不是有效的思维导图文件,如果继续编辑可能导致文件损坏!');
alert(t('This file is not a valid mind map file and may cause file corruption if you continue editing.'));
}
}
minder.importJson(obj);
self._loadStatus = true;
self._changed = false;
}, function(msg){
self._loadStatus = false;
alert('载入文件失败!' + msg);
alert(t('Load file fail!') + msg);
window.parent.OCA.FilesMindMap.hide();
});
},
Expand Down
16 changes: 16 additions & 0 deletions l10n/de.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OC.L10N.register(
"files_mindmap",
{
"New mind map file": "Neue Mindmap-Datei",
"New mind map.km": "Neue Mindmap.km",
"Main Topic": "Zentrales Thema",
"Saving...": "Speichern ...",
"This file is not a valid mind map file and may cause file corruption if you continue editing.": "Diese Datei ist keine gültige Mind Map-Datei und kann zu Dateibeschädigungen führen, wenn Sie mit der Bearbeitung fortfahren.",
"Load file fail!": "Datei laden fehlgeschlagen!",
"File Saved": "Datei gespeichert",
"Save failed": "Speichern fehlgeschlagen",
"Export": "Export",
"Export to PNG": "Export nach PNG",
"Export to SVG": "Export nach SVG"
},"nplurals=1; plural=0;"
);
15 changes: 15 additions & 0 deletions l10n/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"translations": {
"New mind map file": "Neue Mindmap-Datei",
"New mind map.km": "Neue Mindmap.km",
"Main Topic": "Zentrales Thema",
"Saving...": "Speichern ...",
"This file is not a valid mind map file and may cause file corruption if you continue editing.": "Diese Datei ist keine gültige Mind Map-Datei und kann zu Dateibeschädigungen führen, wenn Sie mit der Bearbeitung fortfahren.",
"Load file fail!": "Datei laden fehlgeschlagen!",
"File Saved": "Datei gespeichert",
"Save failed": "Speichern fehlgeschlagen",
"Export": "Export",
"Export to PNG": "Export nach PNG",
"Export to SVG": "Export nach SVG"
},"pluralForm" :"nplurals=1; plural=0;"
}
16 changes: 16 additions & 0 deletions l10n/zh_CN.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
OC.L10N.register(
"files_mindmap",
{
"New mind map file": "新建思维导图文件",
"New mind map.km": "新建思维导图.km",
"Main Topic": "中心主题",
"Saving...": "正在保存...",
"This file is not a valid mind map file and may cause file corruption if you continue editing.": "此文件不是有效的思维导图文件,如果继续编辑可能导致文件损坏!",
"Load file fail!": "载入文件失败!",
"File Saved": "内容已保存",
"Save failed": "保存失败",
"Export": "导出",
"Export to PNG": "导出为PNG图像",
"Export to SVG": "导出为SVG图像"
},"nplurals=1; plural=0;"
);
15 changes: 15 additions & 0 deletions l10n/zh_CN.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"translations": {
"New mind map file": "新建思维导图文件",
"New mind map.km": "新建思维导图.km",
"Main Topic": "中心主题",
"Saving...": "正在保存...",
"This file is not a valid mind map file and may cause file corruption if you continue editing.": "此文件不是有效的思维导图文件,如果继续编辑可能导致文件损坏!",
"Load file fail!": "载入文件失败!",
"File Saved": "内容已保存",
"Save failed": "保存失败",
"Export": "导出",
"Export to PNG": "导出为PNG图像",
"Export to SVG": "导出为SVG图像"
},"pluralForm" :"nplurals=1; plural=0;"
}
11 changes: 5 additions & 6 deletions templates/viewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,18 @@
<div id="export-button" class="btn-group-vertical" dropdown is-open="isopen">
<button type="button"
class="btn btn-default export-caption dropdown-toggle"
title="{{ 'export' | lang:'ui' }}"
title="<?php p($l->t('Export')); ?>"
dropdown-toggle>
<span class="caption">{{ 'export' | lang:'ui' }}</span>
<span class="caption"><?php p($l->t('Export')); ?></span>
<span class="caret"></span>
<span class="sr-only">{{ 'export' | lang:'ui' }}</span>
<span class="sr-only"><?php p($l->t('Export')); ?></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>
<a id="export-png" href">{{ 'exportPNG' | lang:'ui/command' }}</a>
<a id="export-png" href"><?php p($l->t('Export to PNG')); ?></a>
</li>
<li>
<a id="export-svg" href">{{ 'exportSVG' | lang:'ui/command' }}</a>
<a id="export-svg" href"><?php p($l->t('Export to SVG')); ?></a>
</li>
</ul>
</div>
Expand All @@ -142,7 +142,6 @@ class="btn btn-default export-caption dropdown-toggle"
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/marked/lib/marked.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/kity/dist/kity.min.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/hotbox/hotbox.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/json-diff/json-diff.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/kityminder-core/dist/kityminder.core.min.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/color-picker/dist/color-picker.min.js')) ?>?v=<?php p($version) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_mindmap', 'vendor/js-base64/base64.min.js')) ?>?v=<?php p($version) ?>"></script>
Expand Down

0 comments on commit d966a16

Please sign in to comment.