From 43313bc418851111512dbbde5295bf849d8f784b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Arroyo=20Torrens?= Date: Sun, 20 Nov 2016 19:42:31 +0100 Subject: [PATCH 1/9] Use angular-gettext for translation --- .gitignore | 2 + app/bower.json | 3 +- app/index.html | 1 + app/resources/locale/{ => _old}/en.json | 0 app/resources/locale/{ => _old}/es-ES.json | 0 app/resources/locale/{ => _old}/eu.json | 0 app/resources/locale/{ => _old}/fr-FR.json | 0 app/resources/locale/{ => _old}/gl.json | 0 app/resources/locale/en/en.json | 1 + app/resources/locale/en/en.po | 233 +++++++++++ app/resources/locale/es/es.json | 1 + app/resources/locale/es/es.po | 239 ++++++++++++ app/resources/locale/template.pot | 429 +++++++++++++++++++++ app/scripts/app.js | 23 +- app/scripts/controllers/menu.js | 30 +- app/scripts/services/common.service.js | 24 +- app/scripts/services/graph.service.js | 16 +- app/scripts/services/tools.service.js | 46 +-- app/scripts/services/utils.service.js | 28 +- app/views/menu.html | 2 +- gruntfile.js | 35 ++ package.json | 1 + 22 files changed, 1027 insertions(+), 87 deletions(-) rename app/resources/locale/{ => _old}/en.json (100%) rename app/resources/locale/{ => _old}/es-ES.json (100%) rename app/resources/locale/{ => _old}/eu.json (100%) rename app/resources/locale/{ => _old}/fr-FR.json (100%) rename app/resources/locale/{ => _old}/gl.json (100%) create mode 100644 app/resources/locale/en/en.json create mode 100644 app/resources/locale/en/en.po create mode 100644 app/resources/locale/es/es.json create mode 100644 app/resources/locale/es/es.po create mode 100644 app/resources/locale/template.pot diff --git a/.gitignore b/.gitignore index 399b3aed0..c202c8680 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.bin *.blif *.log +*.mo .tmp dist @@ -16,3 +17,4 @@ bower_components app/profile.json app/_cache app/_build +app/resources/locale/**/.json diff --git a/app/bower.json b/app/bower.json index c352491e9..bdc87e504 100644 --- a/app/bower.json +++ b/app/bower.json @@ -36,6 +36,7 @@ "async": "^1.5.2", "svg-pan-zoom": "^3.2.9", "alertify-js": "^1.8.0", - "jquery-resize": "*" + "jquery-resize": "*", + "angular-gettext": "^2.3.8" } } diff --git a/app/index.html b/app/index.html index eaa2b6368..a7e5f817b 100644 --- a/app/index.html +++ b/app/index.html @@ -46,6 +46,7 @@ + diff --git a/app/resources/locale/en.json b/app/resources/locale/_old/en.json similarity index 100% rename from app/resources/locale/en.json rename to app/resources/locale/_old/en.json diff --git a/app/resources/locale/es-ES.json b/app/resources/locale/_old/es-ES.json similarity index 100% rename from app/resources/locale/es-ES.json rename to app/resources/locale/_old/es-ES.json diff --git a/app/resources/locale/eu.json b/app/resources/locale/_old/eu.json similarity index 100% rename from app/resources/locale/eu.json rename to app/resources/locale/_old/eu.json diff --git a/app/resources/locale/fr-FR.json b/app/resources/locale/_old/fr-FR.json similarity index 100% rename from app/resources/locale/fr-FR.json rename to app/resources/locale/_old/fr-FR.json diff --git a/app/resources/locale/gl.json b/app/resources/locale/_old/gl.json similarity index 100% rename from app/resources/locale/gl.json rename to app/resources/locale/_old/gl.json diff --git a/app/resources/locale/en/en.json b/app/resources/locale/en/en.json new file mode 100644 index 000000000..e5d71a564 --- /dev/null +++ b/app/resources/locale/en/en.json @@ -0,0 +1 @@ +{"en":{"Hello!":"Hello!"}} \ No newline at end of file diff --git a/app/resources/locale/en/en.po b/app/resources/locale/en/en.po new file mode 100644 index 000000000..e521e00a8 --- /dev/null +++ b/app/resources/locale/en/en.po @@ -0,0 +1,233 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"X-Generator: Poedit 1.8.7.1\n" +"Last-Translator: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Language: en\n" + +#: app/views/main.html:2 +msgid "Hello!" +msgstr "Hello!" + +#: app/views/menu.html:271 +msgid "about_icestudio" +msgstr "" + +#: app/views/menu.html:281 +msgid "basic" +msgstr "" + +#: app/views/menu.html:152 +msgid "basque" +msgstr "" + +#: app/views/menu.html:185 +msgid "boards" +msgstr "" + +#: app/views/menu.html:203 +msgid "build" +msgstr "" + +#: app/views/menu.html:112 +msgid "clear_all" +msgstr "" + +#: app/views/menu.html:106 +msgid "clone_selected" +msgstr "" + +#: app/views/menu.html:284 +msgid "code" +msgstr "" + +#: app/views/menu.html:267 +msgid "community_forum" +msgstr "" + +#: app/views/menu.html:179 +msgid "datasheet" +msgstr "" + +#: app/views/menu.html:241 +msgid "disable" +msgstr "" + +#: app/views/menu.html:260 +msgid "documentation" +msgstr "" + +#: app/views/menu.html:234 +msgid "drivers" +msgstr "" + +#: app/views/menu.html:99 +msgid "edit" +msgstr "" + +#: app/views/menu.html:237 +msgid "enable" +msgstr "" + +#: app/views/menu.html:134 +msgid "english" +msgstr "" + +#: app/views/menu.html:32 +msgid "examples" +msgstr "" + +#: app/views/menu.html:79 +msgid "export" +msgstr "" + +#: app/views/menu.html:75 +msgid "export_as_block" +msgstr "" + +#: app/views/menu.html:23 +msgid "file" +msgstr "" + +#: app/views/menu.html:158 +msgid "french" +msgstr "" + +#: app/views/menu.html:146 +msgid "galician" +msgstr "" + +#: app/views/menu.html:91 +msgid "gtkwave" +msgstr "" + +#: app/views/menu.html:250 +msgid "help" +msgstr "" + +#: app/views/menu.html:119 +msgid "image_path" +msgstr "" + +#: app/views/menu.html:72 +msgid "import_block" +msgstr "" + +#: app/views/menu.html:285 +msgid "info" +msgstr "" + +#: app/views/menu.html:286 +msgid "input" +msgstr "" + +#: app/views/menu.html:130 +msgid "language" +msgstr "" + +#: app/views/menu.html:26 +msgid "new_project" +msgstr "" + +#: app/views/menu.html:29 +msgid "open_project" +msgstr "" + +#: app/views/menu.html:287 +msgid "output" +msgstr "" + +#: app/views/menu.html:85 +msgid "pcf" +msgstr "" + +#: app/views/menu.html:116 +msgid "preferences" +msgstr "" + +#: app/views/project.html:2 +msgid "read_only" +msgstr "" + +#: app/views/menu.html:124 +msgid "remote_hostname" +msgstr "" + +#: app/views/menu.html:219 +msgid "remove" +msgstr "" + +#: app/views/menu.html:109 +msgid "remove_selected" +msgstr "" + +#: app/views/menu.html:224 +msgid "reset_default" +msgstr "" + +#: app/views/menu.html:102 +msgid "reset_view" +msgstr "" + +#: app/views/menu.html:65 +msgid "save" +msgstr "" + +#: app/views/menu.html:68 +msgid "save_as" +msgstr "" + +#: app/views/menu.html:263 +msgid "source_code" +msgstr "" + +#: app/views/menu.html:140 +msgid "spanish" +msgstr "" + +#: app/views/menu.html:49 +msgid "templates" +msgstr "" + +#: app/views/menu.html:88 +msgid "testbench" +msgstr "" + +#: app/views/menu.html:210 +msgid "toolchain" +msgstr "" + +#: app/views/menu.html:197 +msgid "tools" +msgstr "" + +#: app/views/menu.html:206 +msgid "upload" +msgstr "" + +#: app/views/menu.html:200 +msgid "verify" +msgstr "" + +#: app/views/menu.html:82 +msgid "verilog" +msgstr "" + +#: app/views/menu.html:256 +msgid "version" +msgstr "" + +#: app/views/menu.html:170 +msgid "view" +msgstr "" + +#: app/views/menu.html:253 +msgid "view_license" +msgstr "" diff --git a/app/resources/locale/es/es.json b/app/resources/locale/es/es.json new file mode 100644 index 000000000..ddc0c27d2 --- /dev/null +++ b/app/resources/locale/es/es.json @@ -0,0 +1 @@ +{"es":{"Caca":"Culo"}} \ No newline at end of file diff --git a/app/resources/locale/es/es.po b/app/resources/locale/es/es.po new file mode 100644 index 000000000..4ed4c2ae6 --- /dev/null +++ b/app/resources/locale/es/es.po @@ -0,0 +1,239 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.7.1\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: app/scripts/app.js:29 +msgid "Caca" +msgstr "Culo" + +#: app/views/menu.html:271 +msgid "about_icestudio" +msgstr "" + +#: app/views/menu.html:281 +msgid "basic" +msgstr "" + +#: app/views/menu.html:152 +msgid "basque" +msgstr "" + +#: app/views/menu.html:185 +msgid "boards" +msgstr "" + +#: app/views/menu.html:203 +msgid "build" +msgstr "" + +#: app/views/menu.html:112 +msgid "clear_all" +msgstr "" + +#: app/views/menu.html:106 +msgid "clone_selected" +msgstr "" + +#: app/views/menu.html:284 +msgid "code" +msgstr "" + +#: app/views/menu.html:267 +msgid "community_forum" +msgstr "" + +#: app/views/menu.html:179 +msgid "datasheet" +msgstr "" + +#: app/views/menu.html:241 +msgid "disable" +msgstr "" + +#: app/views/menu.html:260 +msgid "documentation" +msgstr "" + +#: app/views/menu.html:234 +msgid "drivers" +msgstr "" + +#: app/views/menu.html:99 +msgid "edit" +msgstr "" + +#: app/views/menu.html:237 +msgid "enable" +msgstr "" + +#: app/views/menu.html:134 +msgid "english" +msgstr "" + +#: app/views/menu.html:32 +msgid "examples" +msgstr "" + +#: app/views/menu.html:79 +msgid "export" +msgstr "" + +#: app/views/menu.html:75 +msgid "export_as_block" +msgstr "" + +#: app/views/menu.html:23 +msgid "file" +msgstr "" + +#: app/views/menu.html:158 +msgid "french" +msgstr "" + +#: app/views/menu.html:146 +msgid "galician" +msgstr "" + +#: app/views/menu.html:91 +msgid "gtkwave" +msgstr "" + +#: app/views/menu.html:250 +msgid "help" +msgstr "" + +#: app/views/menu.html:119 +msgid "image_path" +msgstr "" + +#: app/views/menu.html:72 +msgid "import_block" +msgstr "" + +#: app/views/menu.html:285 +msgid "info" +msgstr "" + +#: app/views/menu.html:286 +msgid "input" +msgstr "" + +#: app/views/menu.html:130 +msgid "language" +msgstr "" + +#: app/views/menu.html:26 +msgid "new_project" +msgstr "" + +#: app/views/menu.html:29 +msgid "open_project" +msgstr "" + +#: app/views/menu.html:287 +msgid "output" +msgstr "" + +#: app/views/menu.html:85 +msgid "pcf" +msgstr "" + +#: app/views/menu.html:116 +msgid "preferences" +msgstr "" + +#: app/views/project.html:2 +msgid "read_only" +msgstr "" + +#: app/views/menu.html:124 +msgid "remote_hostname" +msgstr "" + +#: app/views/menu.html:219 +msgid "remove" +msgstr "" + +#: app/views/menu.html:109 +msgid "remove_selected" +msgstr "" + +#: app/views/menu.html:224 +msgid "reset_default" +msgstr "" + +#: app/views/menu.html:102 +msgid "reset_view" +msgstr "" + +#: app/views/menu.html:65 +msgid "save" +msgstr "" + +#: app/views/menu.html:68 +msgid "save_as" +msgstr "" + +#: app/views/menu.html:263 +msgid "source_code" +msgstr "" + +#: app/views/menu.html:140 +msgid "spanish" +msgstr "" + +#: app/views/menu.html:49 +msgid "templates" +msgstr "" + +#: app/views/menu.html:88 +msgid "testbench" +msgstr "" + +#: app/views/menu.html:210 +msgid "toolchain" +msgstr "" + +#: app/views/menu.html:197 +msgid "tools" +msgstr "" + +#: app/views/menu.html:206 +msgid "upload" +msgstr "" + +#: app/views/menu.html:200 +msgid "verify" +msgstr "" + +#: app/views/menu.html:82 +msgid "verilog" +msgstr "" + +#: app/views/menu.html:256 +msgid "version" +msgstr "" + +#: app/views/menu.html:170 +msgid "view" +msgstr "" + +#: app/views/menu.html:253 +msgid "view_license" +msgstr "" + +#~ msgid "Momo" +#~ msgstr "Mumu" + +#~ msgid "Hello!" +#~ msgstr "¡Hola!" diff --git a/app/resources/locale/template.pot b/app/resources/locale/template.pot new file mode 100644 index 000000000..db24d960e --- /dev/null +++ b/app/resources/locale/template.pot @@ -0,0 +1,429 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Project-Id-Version: \n" + +#: app/views/menu.html:23 +msgid "File" +msgstr "" + +#: app/views/menu.html:271 +msgid "about_icestudio" +msgstr "" + +#: app/views/menu.html:281 +msgid "basic" +msgstr "" + +#: app/views/menu.html:152 +msgid "basque" +msgstr "" + +#: app/scripts/services/common.service.js:94 +msgid "block_exported_as" +msgstr "" + +#: app/scripts/services/common.service.js:75 +msgid "block_imported" +msgstr "" + +#: app/scripts/services/tools.service.js:210 +msgid "board_not_detected" +msgstr "" + +#: app/scripts/controllers/menu.js:406 +#: app/scripts/controllers/menu.js:412 +msgid "board_selected" +msgstr "" + +#: app/views/menu.html:185 +msgid "boards" +msgstr "" + +#: app/views/menu.html:203 +msgid "build" +msgstr "" + +#: app/scripts/controllers/menu.js:402 +msgid "change_board_confirmation" +msgstr "" + +#: app/views/menu.html:112 +msgid "clear_all" +msgstr "" + +#: app/scripts/controllers/menu.js:313 +msgid "clear_all_confirmation" +msgstr "" + +#: app/views/menu.html:106 +msgid "clone_selected" +msgstr "" + +#: app/views/menu.html:284 +msgid "code" +msgstr "" + +#: app/views/menu.html:267 +msgid "community_forum" +msgstr "" + +#: app/views/menu.html:179 +msgid "datasheet" +msgstr "" + +#: app/scripts/controllers/menu.js:393 +msgid "datasheet_not_defined" +msgstr "" + +#: app/views/menu.html:241 +msgid "disable" +msgstr "" + +#: app/views/menu.html:260 +msgid "documentation" +msgstr "" + +#: app/scripts/services/tools.service.js:256 +msgid "done_" +msgstr "" + +#: app/views/menu.html:234 +msgid "drivers" +msgstr "" + +#: app/scripts/services/utils.service.js:411 +#: app/scripts/services/utils.service.js:474 +msgid "drivers_disabled" +msgstr "" + +#: app/scripts/services/utils.service.js:408 +#: app/scripts/services/utils.service.js:455 +msgid "drivers_enabled" +msgstr "" + +#: app/scripts/services/tools.service.js:222 +msgid "duplicated_fpga_io" +msgstr "" + +#: app/views/menu.html:99 +msgid "edit" +msgstr "" + +#: app/views/menu.html:237 +msgid "enable" +msgstr "" + +#: app/views/menu.html:134 +msgid "english" +msgstr "" + +#: app/scripts/services/graph.service.js:257 +#: app/scripts/services/graph.service.js:464 +#: app/scripts/services/graph.service.js:504 +msgid "enter_block_label" +msgstr "" + +#: app/scripts/services/graph.service.js:409 +msgid "enter_block_ports" +msgstr "" + +#: app/scripts/controllers/menu.js:290 +msgid "enter_project_image_path" +msgstr "" + +#: app/scripts/controllers/menu.js:72 +msgid "enter_project_title" +msgstr "" + +#: app/scripts/controllers/menu.js:298 +msgid "enter_remote_hostname" +msgstr "" + +#: app/views/menu.html:32 +msgid "examples" +msgstr "" + +#: app/scripts/services/tools.service.js:181 +msgid "execute_remote" +msgstr "" + +#: app/views/menu.html:79 +msgid "export" +msgstr "" + +#: app/views/menu.html:75 +msgid "export_as_block" +msgstr "" + +#: app/scripts/services/tools.service.js:147 +msgid "file_does_not_exist" +msgstr "" + +#: app/scripts/services/tools.service.js:216 +#: app/scripts/services/tools.service.js:219 +msgid "fpga_io_not_defined" +msgstr "" + +#: app/views/menu.html:158 +msgid "french" +msgstr "" + +#: app/views/menu.html:146 +msgid "galician" +msgstr "" + +#: app/scripts/services/tools.service.js:153 +msgid "generic_error" +msgstr "" + +#: app/views/menu.html:91 +msgid "gtkwave" +msgstr "" + +#: app/scripts/services/common.service.js:134 +msgid "gtkwave_exported" +msgstr "" + +#: app/views/menu.html:250 +msgid "help" +msgstr "" + +#: app/scripts/services/utils.service.js:445 +msgid "homebrew_required" +msgstr "" + +#: app/views/menu.html:119 +msgid "image_path" +msgstr "" + +#: app/views/menu.html:72 +msgid "import_block" +msgstr "" + +#: app/views/menu.html:285 +msgid "info" +msgstr "" + +#: app/views/menu.html:286 +msgid "input" +msgstr "" + +#: app/scripts/services/utils.service.js:480 +msgid "install_drivers_windows" +msgstr "" + +#: app/scripts/services/tools.service.js:476 +msgid "installation_completed" +msgstr "" + +#: app/scripts/services/tools.service.js:319 +#: app/scripts/services/tools.service.js:356 +msgid "installing_toolchain" +msgstr "" + +#: app/scripts/services/tools.service.js:392 +#: app/scripts/services/utils.service.js:448 +msgid "internet_connection_required" +msgstr "" + +#: app/scripts/services/graph.service.js:261 +msgid "label_updated" +msgstr "" + +#: app/views/menu.html:130 +msgid "language" +msgstr "" + +#: app/scripts/controllers/menu.js:117 +#: app/scripts/controllers/menu.js:94 +msgid "load_project_confirmation" +msgstr "" + +#: app/views/menu.html:26 +msgid "new_project" +msgstr "" + +#: app/views/menu.html:29 +msgid "open_project" +msgstr "" + +#: app/views/menu.html:287 +msgid "output" +msgstr "" + +#: app/views/menu.html:85 +msgid "pcf" +msgstr "" + +#: app/scripts/services/common.service.js:114 +msgid "pcf_exported" +msgstr "" + +#: app/views/menu.html:116 +msgid "preferences" +msgstr "" + +#: app/scripts/services/common.service.js:31 +msgid "project_created" +msgstr "" + +#: app/scripts/services/common.service.js:51 +msgid "project_loaded" +msgstr "" + +#: app/scripts/services/common.service.js:63 +msgid "project_saved" +msgstr "" + +#: app/views/project.html:2 +msgid "read_only" +msgstr "" + +#: app/scripts/services/tools.service.js:248 +msgid "remote_host_not_connected" +msgstr "" + +#: app/views/menu.html:124 +msgid "remote_hostname" +msgstr "" + +#: app/views/menu.html:219 +msgid "remove" +msgstr "" + +#: app/scripts/controllers/menu.js:326 +msgid "remove_block_confirmation" +msgstr "" + +#: app/views/menu.html:109 +msgid "remove_selected" +msgstr "" + +#: app/scripts/services/tools.service.js:295 +msgid "remove_toolchain_confirmation" +msgstr "" + +#: app/views/menu.html:224 +msgid "reset_default" +msgstr "" + +#: app/views/menu.html:102 +msgid "reset_view" +msgstr "" + +#: app/views/menu.html:65 +msgid "save" +msgstr "" + +#: app/views/menu.html:68 +msgid "save_as" +msgstr "" + +#: app/views/menu.html:263 +msgid "source_code" +msgstr "" + +#: app/views/menu.html:140 +msgid "spanish" +msgstr "" + +#: app/scripts/services/tools.service.js:41 +msgid "start_" +msgstr "" + +#: app/scripts/services/tools.service.js:170 +msgid "sync_remote_files" +msgstr "" + +#: app/views/menu.html:49 +msgid "templates" +msgstr "" + +#: app/views/menu.html:88 +msgid "testbench" +msgstr "" + +#: app/scripts/services/common.service.js:124 +msgid "testbench_exported" +msgstr "" + +#: app/views/menu.html:210 +msgid "toolchain" +msgstr "" + +#: app/scripts/services/tools.service.js:477 +msgid "toolchain_installed" +msgstr "" + +#: app/scripts/services/tools.service.js:71 +#: app/scripts/services/utils.service.js:486 +#: app/scripts/services/utils.service.js:502 +msgid "toolchain_not_installed" +msgstr "" + +#: app/scripts/services/tools.service.js:299 +msgid "toolchain_removed" +msgstr "" + +#: app/views/menu.html:197 +msgid "tools" +msgstr "" + +#: app/scripts/services/utils.service.js:496 +msgid "uninstall_drivers_windows" +msgstr "" + +#: app/scripts/services/tools.service.js:213 +msgid "unknown_board" +msgstr "" + +#: app/scripts/services/utils.service.js:414 +#: app/scripts/services/utils.service.js:489 +msgid "unplug_and_reconnect" +msgstr "" + +#: app/scripts/controllers/menu.js:73 +msgid "untitled" +msgstr "" + +#: app/views/menu.html:206 +msgid "upload" +msgstr "" + +#: app/views/menu.html:200 +msgid "verify" +msgstr "" + +#: app/views/menu.html:82 +msgid "verilog" +msgstr "" + +#: app/scripts/services/common.service.js:104 +msgid "verilog_exported" +msgstr "" + +#: app/views/menu.html:256 +msgid "version" +msgstr "" + +#: app/views/menu.html:170 +msgid "view" +msgstr "" + +#: app/views/menu.html:253 +msgid "view_license" +msgstr "" + +#: app/scripts/services/graph.service.js:561 +msgid "wrong_block_format" +msgstr "" + +#: app/scripts/services/common.service.js:54 +msgid "wrong_project_format" +msgstr "" + +#: app/scripts/services/tools.service.js:245 +msgid "wrong_remote_hostname" +msgstr "" diff --git a/app/scripts/app.js b/app/scripts/app.js index a748c4c7b..b47128233 100644 --- a/app/scripts/app.js +++ b/app/scripts/app.js @@ -3,10 +3,10 @@ angular .module('icestudio', [ 'ngRoute', - 'pascalprecht.translate', - 'ui.bootstrap' - ]).config(['$routeProvider', '$translateProvider', - function($routeProvider, $translateProvider) { + 'ui.bootstrap', + 'gettext' + ]).config(['$routeProvider', + function($routeProvider) { $routeProvider .when('/', { @@ -16,17 +16,12 @@ angular .otherwise({ redirectTo: '/' }); - $translateProvider.useStaticFilesLoader({ - prefix: 'resources/locale/', - suffix: '.json' - }); - - // Initial language - $translateProvider.preferredLanguage('en'); - //$translateProvider.useSanitizeValueStrategy('escape'); } ]) - .run(function(nodeFs) { - // console.log('Start'); + .run(function(gettextCatalog) { + // Initial language + var lang = 'es'; + gettextCatalog.setCurrentLanguage(lang); + gettextCatalog.loadRemote('resources/locale/' + lang + '/' + lang + '.json'); }); diff --git a/app/scripts/controllers/menu.js b/app/scripts/controllers/menu.js index e03fae639..5f2879aba 100644 --- a/app/scripts/controllers/menu.js +++ b/app/scripts/controllers/menu.js @@ -3,7 +3,7 @@ angular.module('icestudio') .controller('MenuCtrl', function ($scope, $timeout, - $translate, + gettextCatalog, common, graph, tools, @@ -17,7 +17,9 @@ angular.module('icestudio') // Manage language profile.load(function() { - $translate.use(profile.data.language); + var lang = profile.data.language; + gettextCatalog.setCurrentLanguage(lang); + gettextCatalog.loadRemote('resources/locale/' + lang + '/' + lang + '.json'); }); var win = gui.Window.get(); win.on('close', function() { @@ -67,8 +69,8 @@ angular.module('icestudio') // File $scope.newProject = function() { - alertify.prompt($translate.instant('enter_project_title'), - $translate.instant('untitled'), + alertify.prompt(gettextCatalog.getString('enter_project_title'), + gettextCatalog.getString('untitled'), function(evt, name) { if (name) { common.newProject(name); @@ -89,7 +91,7 @@ angular.module('icestudio') $scope.workingdir = utils.dirname(file.path) + utils.sep; if (!graph.isEmpty()) { - alertify.confirm($translate.instant('load_project_confirmation'), + alertify.confirm(gettextCatalog.getString('load_project_confirmation'), function() { common.openProject(file.path); $scope.currentProjectPath = file.path; @@ -112,7 +114,7 @@ angular.module('icestudio') $scope.openStoredProject = function(name, project) { if (project) { if (!graph.isEmpty()) { - alertify.confirm($translate.instant('load_project_confirmation'), + alertify.confirm(gettextCatalog.getString('load_project_confirmation'), function() { common.loadProject(name, project); $scope.currentProjectPath = ''; @@ -285,7 +287,7 @@ angular.module('icestudio') $scope.setImagePath = function() { var current = common.project.image; - alertify.prompt($translate.instant('enter_project_image_path'), (current) ? current : '', + alertify.prompt(gettextCatalog.getString('enter_project_image_path'), (current) ? current : '', function(evt, imagePath) { common.setImagePath(imagePath); }); @@ -293,7 +295,7 @@ angular.module('icestudio') $scope.setRemoteHostname = function() { var current = profile.data.remoteHostname; - alertify.prompt($translate.instant('enter_remote_hostname'), (current) ? current : '', + alertify.prompt(gettextCatalog.getString('enter_remote_hostname'), (current) ? current : '', function(evt, remoteHostname) { profile.data.remoteHostname = remoteHostname; }); @@ -308,7 +310,7 @@ angular.module('icestudio') $scope.clearGraph = function() { if (!graph.isEmpty()) { - alertify.confirm($translate.instant('clear_all_confirmation'), + alertify.confirm(gettextCatalog.getString('clear_all_confirmation'), function() { common.clearProject(); }); @@ -321,7 +323,7 @@ angular.module('icestudio') $scope.removeSelected = function() { if (graph.hasSelection()) { - alertify.confirm($translate.instant('remove_block_confirmation'), + alertify.confirm(gettextCatalog.getString('remove_block_confirmation'), function() { common.removeSelected(); }); @@ -388,7 +390,7 @@ angular.module('icestudio') gui.Shell.openExternal(boards.selectedBoard.info.datasheet); } else { - alertify.error($translate.instant('datasheet_not_defined')); + alertify.error(gettextCatalog.getString('datasheet_not_defined')); } } @@ -397,17 +399,17 @@ angular.module('icestudio') $scope.selectBoard = function(board) { if (boards.selectedBoard.name != board.name) { if (!graph.isEmpty()) { - alertify.confirm($translate.instant('change_board_confirmation', { name: '' + board.info.label + '' }), + alertify.confirm(gettextCatalog.getString('change_board_confirmation', { name: '' + board.info.label + '' }), function() { boards.selectBoard(board.name); graph.resetIOChoices(); - alertify.success($translate.instant('board_selected', { name: '' + board.info.label + '' })); + alertify.success(gettextCatalog.getString('board_selected', { name: '' + board.info.label + '' })); }); } else { boards.selectBoard(board.name); graph.resetIOChoices(); - alertify.success($translate.instant('board_selected', { name: '' + board.info.label + '' })); + alertify.success(gettextCatalog.getString('board_selected', { name: '' + board.info.label + '' })); } } } diff --git a/app/scripts/services/common.service.js b/app/scripts/services/common.service.js index c90db217c..510d11f35 100644 --- a/app/scripts/services/common.service.js +++ b/app/scripts/services/common.service.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('icestudio') - .service('common', ['$rootScope', '$translate', 'window', 'graph', 'boards', 'compiler', 'utils', - function($rootScope, $translate, window, graph, boards, compiler, utils) { + .service('common', ['$rootScope', 'gettextCatalog', 'window', 'graph', 'boards', 'compiler', 'utils', + function($rootScope, gettextCatalog, window, graph, boards, compiler, utils) { // Variables @@ -28,7 +28,7 @@ angular.module('icestudio') graph.clearAll(); graph.setState(this.project.state); this.updateProjectName(name); - alertify.success($translate.instant('project_created', { name: name })); + alertify.success(gettextCatalog.getString('project_created', { name: name })); }; this.openProject = function(filepath) { @@ -48,10 +48,10 @@ angular.module('icestudio') this.project = project; boards.selectBoard(project.board); if (graph.loadGraph(project)) { - alertify.success($translate.instant('project_loaded', { name: name })); + alertify.success(gettextCatalog.getString('project_loaded', { name: name })); } else { - alertify.error($translate.instant('wrong_project_format', { name: name })); + alertify.error(gettextCatalog.getString('wrong_project_format', { name: name })); } }; @@ -60,7 +60,7 @@ angular.module('icestudio') this.updateProjectName(name); this.refreshProject(); utils.saveFile(filepath, this.project, function() { - alertify.success($translate.instant('project_saved', { name: name })); + alertify.success(gettextCatalog.getString('project_saved', { name: name })); }, true); }; @@ -72,7 +72,7 @@ angular.module('icestudio') var name = utils.basename(filepath); graph.importBlock(name, block); _this.project.deps[name] = block; - alertify.success($translate.instant('block_imported', { name: name })); + alertify.success(gettextCatalog.getString('block_imported', { name: name })); } }; })(this)); @@ -91,7 +91,7 @@ angular.module('icestudio') } } utils.saveFile(filepath, block, function() { - alertify.success($translate.instant('block_exported_as', { name: name })); + alertify.success(gettextCatalog.getString('block_exported_as', { name: name })); }, true); }; @@ -101,7 +101,7 @@ angular.module('icestudio') // Generate verilog code from project var verilog = compiler.generateVerilog(this.project); utils.saveFile(filepath, verilog, function() { - alertify.success($translate.instant('verilog_exported')); + alertify.success(gettextCatalog.getString('verilog_exported')); }, false); }; @@ -111,7 +111,7 @@ angular.module('icestudio') // Generate pcf code from project var pcf = compiler.generatePCF(this.project); utils.saveFile(filepath, pcf, function() { - alertify.success($translate.instant('pcf_exported')); + alertify.success(gettextCatalog.getString('pcf_exported')); }, false); }; @@ -121,7 +121,7 @@ angular.module('icestudio') // Generate testbench code from project var testbench = compiler.generateTestbench(this.project); utils.saveFile(filepath, testbench, function() { - alertify.success($translate.instant('testbench_exported')); + alertify.success(gettextCatalog.getString('testbench_exported')); }, false); }; @@ -131,7 +131,7 @@ angular.module('icestudio') // Generate gtkwave code from project var gtkwave = compiler.generateGTKWave(this.project); utils.saveFile(filepath, gtkwave, function() { - alertify.success($translate.instant('gtkwave_exported')); + alertify.success(gettextCatalog.getString('gtkwave_exported')); }, false); }; diff --git a/app/scripts/services/graph.service.js b/app/scripts/services/graph.service.js index 10a2af712..555286b10 100644 --- a/app/scripts/services/graph.service.js +++ b/app/scripts/services/graph.service.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('icestudio') - .service('graph', ['$rootScope', '$translate', 'nodeFs', 'joint', 'boards', 'nodeSha1', - function($rootScope, $translate, nodeFs, joint, boards, nodeSha1) { + .service('graph', ['$rootScope', 'gettextCatalog', 'nodeFs', 'joint', 'boards', 'nodeSha1', + function($rootScope, gettextCatalog, nodeFs, joint, boards, nodeSha1) { // Variables @@ -254,11 +254,11 @@ angular.module('icestudio') if (data.blockType == 'basic.input' || data.blockType == 'basic.output') { if (paper.options.enabled) { - alertify.prompt($translate.instant('enter_block_label'), data.data.label, + alertify.prompt(gettextCatalog.getString('enter_block_label'), data.data.label, function(evt, label) { data.data.label = label; cellView.renderLabel(); - alertify.success($translate.instant('label_updated')); + alertify.success(gettextCatalog.getString('label_updated')); }); } } @@ -406,7 +406,7 @@ angular.module('icestudio') }; if (type == 'basic.code') { - alertify.prompt($translate.instant('enter_block_ports'), 'a,b c', + alertify.prompt(gettextCatalog.getString('enter_block_ports'), 'a,b c', function(evt, ports) { if (ports) { blockInstance.data = { @@ -461,7 +461,7 @@ angular.module('icestudio') } } else if (type == 'basic.input') { - alertify.prompt($translate.instant('enter_block_label'), 'i', + alertify.prompt(gettextCatalog.getString('enter_block_label'), 'i', function(evt, name) { if (name) { var names = name.split(' '); @@ -501,7 +501,7 @@ angular.module('icestudio') }); } else if (type == 'basic.output') { - alertify.prompt($translate.instant('enter_block_label'), 'o', + alertify.prompt(gettextCatalog.getString('enter_block_label'), 'o', function(evt, name) { if (name) { var names = name.split(' '); @@ -558,7 +558,7 @@ angular.module('icestudio') } } else { - alertify.error($translate.instant('wrong_block_format', { type: type })); + alertify.error(gettextCatalog.getString('wrong_block_format', { type: type })); } } }; diff --git a/app/scripts/services/tools.service.js b/app/scripts/services/tools.service.js index 00add871c..b4b9dbe28 100644 --- a/app/scripts/services/tools.service.js +++ b/app/scripts/services/tools.service.js @@ -1,8 +1,8 @@ 'use strict'; angular.module('icestudio') - .service('tools', ['$translate', 'profile', 'nodeFs', 'nodeFse', 'nodeOs', 'nodePath', 'nodeProcess', 'nodeChildProcess', 'nodeSSHexec', 'nodeRSync', 'common', 'boards', 'compiler', 'utils', - function($translate, profile, nodeFs, nodeFse, nodeOs, nodePath, nodeProcess, nodeChildProcess, nodeSSHexec, nodeRSync, common, boards, compiler, utils) { + .service('tools', ['gettextCatalog', 'profile', 'nodeFs', 'nodeFse', 'nodeOs', 'nodePath', 'nodeProcess', 'nodeChildProcess', 'nodeSSHexec', 'nodeRSync', 'common', 'boards', 'compiler', 'utils', + function(gettextCatalog, profile, nodeFs, nodeFse, nodeOs, nodePath, nodeProcess, nodeChildProcess, nodeSSHexec, nodeRSync, common, boards, compiler, utils) { var currentAlert = null; var toolchain = { apio: '-', installed: false, disabled: false }; @@ -38,7 +38,7 @@ angular.module('icestudio') if (code) { if (toolchain.installed || toolchain.disabled) { angular.element('#menu').addClass('disable-menu'); - currentAlert = alertify.notify($translate.instant('start_' + commands[0]), 'message', 100000); + currentAlert = alertify.notify(gettextCatalog.getString('start_' + commands[0]), 'message', 100000); $('body').addClass('waiting'); nodeProcess.chdir(this.buildPath); check = this.syncResources(code); @@ -68,7 +68,7 @@ angular.module('icestudio') } } else { - alertify.notify($translate.instant('toolchain_not_installed'), 'error', 5); + alertify.notify(gettextCatalog.getString('toolchain_not_installed'), 'error', 5); } } } @@ -144,13 +144,13 @@ angular.module('icestudio') } else { // Error: file does not exist - alertify.notify($translate.instant('file_does_not_exist', { file: file }), 'error', 3); + alertify.notify(gettextCatalog.getString('file_does_not_exist', { file: file }), 'error', 3); ret = false; break; } } catch (e) { - alertify.notify($translate.instant('generic_error', { error: e.toString() }), 'error', 3); + alertify.notify(gettextCatalog.getString('generic_error', { error: e.toString() }), 'error', 3); ret = false; break; } @@ -167,7 +167,7 @@ angular.module('icestudio') var remoteHostname = profile.data.remoteHostname; if (remoteHostname) { - currentAlert.setContent($translate.instant('sync_remote_files')); + currentAlert.setContent(gettextCatalog.getString('sync_remote_files')); nodeRSync({ src: nodeProcess.cwd() + '/', dest: remoteHostname + ':' + this.buildPath + '/', @@ -178,7 +178,7 @@ angular.module('icestudio') exclude: ['.sconsign.dblite', '*.out', '*.blif', '*.asc', '*.bin'] }, function (error, stdout, stderr, cmd) { if (!error) { - currentAlert.setContent($translate.instant('execute_remote', { label: label })); + currentAlert.setContent(gettextCatalog.getString('execute_remote', { label: label })); nodeSSHexec('cd ' + this.buildPath + '; ' + (['apio'].concat(commands)).join(' '), remoteHostname, function (error, stdout, stderr) { processExecute(label, callback, error, stdout, stderr); @@ -207,19 +207,19 @@ angular.module('icestudio') if (stdout) { if (stdout.indexOf('[upload] Error') != -1 || stdout.indexOf('Error: board not detected') != -1) { - alertify.notify($translate.instant('board_not_detected', { name: '' + boards.selectedBoard.info.label + '' }), 'error', 3); + alertify.notify(gettextCatalog.getString('board_not_detected', { name: '' + boards.selectedBoard.info.label + '' }), 'error', 3); } else if (stdout.indexOf('Error: unkown board') != -1) { - alertify.notify($translate.instant('unknown_board'), 'error', 3); + alertify.notify(gettextCatalog.getString('unknown_board'), 'error', 3); } else if (stdout.indexOf('set_io: too few arguments') != -1) { - alertify.notify($translate.instant('fpga_io_not_defined'), 'error', 3); + alertify.notify(gettextCatalog.getString('fpga_io_not_defined'), 'error', 3); } else if (stdout.indexOf('error: unknown pin') != -1) { - alertify.notify($translate.instant('fpga_io_not_defined'), 'error', 3); + alertify.notify(gettextCatalog.getString('fpga_io_not_defined'), 'error', 3); } else if (stdout.indexOf('error: duplicate pin constraints') != -1) { - alertify.notify($translate.instant('duplicated_fpga_io'), 'error', 3); + alertify.notify(gettextCatalog.getString('duplicated_fpga_io'), 'error', 3); } else { var stdoutError = stdout.split('\n').filter(isError); @@ -242,10 +242,10 @@ angular.module('icestudio') else if (stderr) { if (stderr.indexOf('Could not resolve hostname') != -1 || stderr.indexOf('Connection refused') != -1) { - alertify.notify($translate.instant('wrong_remote_hostname', { name: profile.data.remoteHostname }), 'error', 3); + alertify.notify(gettextCatalog.getString('wrong_remote_hostname', { name: profile.data.remoteHostname }), 'error', 3); } else if (stderr.indexOf('No route to host') != -1) { - alertify.notify($translate.instant('remote_host_not_connected', { name: profile.data.remoteHostname }), 'error', 3); + alertify.notify(gettextCatalog.getString('remote_host_not_connected', { name: profile.data.remoteHostname }), 'error', 3); } else { alertify.notify(stderr, 'error', 5); @@ -253,7 +253,7 @@ angular.module('icestudio') } } else { - alertify.success($translate.instant('done_' + label)); + alertify.success(gettextCatalog.getString('done_' + label)); } $('body').removeClass('waiting'); } @@ -292,11 +292,11 @@ angular.module('icestudio') } this.removeToolchain = function() { - alertify.confirm($translate.instant('remove_toolchain_confirmation'), + alertify.confirm(gettextCatalog.getString('remove_toolchain_confirmation'), function() { utils.removeToolchain(); toolchain.installed = false; - alertify.success($translate.instant('toolchain_removed')); + alertify.success(gettextCatalog.getString('toolchain_removed')); }); } @@ -316,7 +316,7 @@ angular.module('icestudio') var content = [ '
', - '

' + $translate.instant('installing_toolchain') + '

', + '

' + gettextCatalog.getString('installing_toolchain') + '

', '
', '
', '
', - '

' + $translate.instant('installing_toolchain') + '

', + '

' + gettextCatalog.getString('installing_toolchain') + '

', '
', '
', '
-1); const DARWIN = Boolean(process.platform.indexOf('darwin') > -1); @@ -405,13 +405,13 @@ angular.module('icestudio') endLazyProcess(); if (!error) { if (enable) { - alertify.success($translate.instant('drivers_enabled')); + alertify.success(gettextCatalog.getString('drivers_enabled')); } else { - alertify.warning($translate.instant('drivers_disabled')); + alertify.warning(gettextCatalog.getString('drivers_disabled')); } setTimeout(function() { - alertify.notify($translate.instant('unplug_and_reconnect'), 'message', 5); + alertify.notify(gettextCatalog.getString('unplug_and_reconnect'), 'message', 5); }, 1000); } }); @@ -442,17 +442,17 @@ angular.module('icestudio') if (error) { if ((stderr.indexOf('brew: command not found') != -1) || (stderr.indexOf('brew: No such file or directory') != -1)) { - alertify.notify($translate.instant('homebrew_required'), 'error', 5); + alertify.notify(gettextCatalog.getString('homebrew_required'), 'error', 5); } else if (stderr.indexOf('Error: Failed to download') != -1) { - alertify.notify($translate.instant('internet_connection_required'), 'error', 5); + alertify.notify(gettextCatalog.getString('internet_connection_required'), 'error', 5); } else { alertify.notify(stderr, 'error', 5); } } else { - alertify.success($translate.instant('drivers_enabled')); + alertify.success(gettextCatalog.getString('drivers_enabled')); } }); } @@ -471,35 +471,35 @@ angular.module('icestudio') // console.log(error, stdout, stderr); endLazyProcess(); if (!error) { - alertify.warning($translate.instant('drivers_disabled')); + alertify.warning(gettextCatalog.getString('drivers_disabled')); } }); } function enableWindowsDrivers() { - alertify.confirm($translate.instant('install_drivers_windows'), function() { + alertify.confirm(gettextCatalog.getString('install_drivers_windows'), function() { beginLazyProcess(); nodeChildProcess.exec([APIO_CMD, 'drivers', '--enable'].join(' '), function(error, stdout, stderr) { // console.log(error, stdout, stderr); endLazyProcess(); if (stderr) { - alertify.notify($translate.instant('toolchain_not_installed'), 'error', 5); + alertify.notify(gettextCatalog.getString('toolchain_not_installed'), 'error', 5); } if (!error) { - alertify.notify($translate.instant('unplug_and_reconnect'), 'message', 5); + alertify.notify(gettextCatalog.getString('unplug_and_reconnect'), 'message', 5); } }); }); } function disableWindowsDrivers() { - alertify.confirm($translate.instant('uninstall_drivers_windows'), function() { + alertify.confirm(gettextCatalog.getString('uninstall_drivers_windows'), function() { beginLazyProcess(); nodeChildProcess.exec([APIO_CMD, 'drivers', '--disable'].join(' '), function(error, stdout, stderr) { // console.log(error, stdout, stderr); endLazyProcess(); if (stderr) { - alertify.notify($translate.instant('toolchain_not_installed'), 'error', 5); + alertify.notify(gettextCatalog.getString('toolchain_not_installed'), 'error', 5); } }); }); diff --git a/app/views/menu.html b/app/views/menu.html index f67671f1f..64baa376f 100644 --- a/app/views/menu.html +++ b/app/views/menu.html @@ -20,7 +20,7 @@