英文:
How Do I translate an Angular Electron App
问题
我正在尝试将一个 en-us(美国英语)的 Angular Electron 应用程序翻译成 es-419(拉丁美洲西班牙语),但我似乎找不到有关如何进行此操作的 Electron 文档信息。
对于国际化 Angular+Electron 应用程序,最常见/流行的方式是什么?
我曾以为这只需要按照 Angular 文档中的说明来完成,因此我按照他们网站上提供的说明进行操作,但我无法弄清楚如何将 electron 编译器指向我的应用程序的特定分发目录。
如果我尝试将 win.loadURL() 设置为特定语言分发文件夹中特定 index.html 的直接路径,项目将运行,但什么都不会渲染。我怀疑它没有检测到任何 .js 文件,因为开发控制台会产生相关错误信息。
如果我将应用程序的本地化设置为 false,应用程序将如预期般正常运行,只需将 win.loadURL() 更改为以下内容:
win.loadURL(file://${__dirname}/dist/app-name/index.html
); // 加载应用程序的 index.html。
当然,不需要在我的 "dist" 文件夹中使用单独的本地化文件夹,我可以直接调用 "app-name" 文件夹中的索引文件。
翻译不需要是动态的(我可以有完全分开的 .exe 文件用于英语和西班牙语),但由于这个应用程序的大小,我不想维护两个单独的代码版本。
英文:
I'm trying to translate a en-us (United States English) Angular Electron app to es-419 (Latin American Spanish), but I can't seem to find any information on the Electron documentation on how to go about this.
What is the most common/popular way to internationalize Angular+Electron apps?
I had assumed this would just be done following the instructions found within the angular documentation, so I followed the instructions provided on their site, but I couldn't figure out how to point the electron compiler to a specific distribution of my app.
If I try to give win.loadURL() the direct path to a specific index.html within a language specific dist folder, the project would run but nothing would render. I suspect it wasn't detecting any .js files because the dev console would produce errors saying such.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
win.loadURL(`file://${__dirname}/dist/app-name/es-419/index.html`); // Load the index.html of the app.
<!-- end snippet -->
But if I would run the app with localization set to false, the application would run as expected without issue by only changing the win.LoadURL() to
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
win.loadURL(`file://${__dirname}/dist/app-name/index.html`); // Load the index.html of the app.
<!-- end snippet -->
Of course, without need for separate localization folders in my "dist" folder I'm able to just call the index file inside "app-name".
The translations do not need to be dynamic (I can have completely separate .exe files for both English and Spanish), but due to the size of this app I don't want to maintain two separate code versions.
答案1
得分: 0
I used Transloco to translate my whole app, I couldn't get anything else to work. If you just manually set a language at the beginning screen, your whole app will be translated.
英文:
I used Transloco to translate my whole app, I couldn't get anything else to work. If you just manually set a language at the beginning screen, your whole app will be translated.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论