-
Notifications
You must be signed in to change notification settings - Fork 71
Integrate localized strings into web and desktop app #2730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3dfeb0f
Added fake localizer
dpwatrous a40d8b2
Switch desktop app to use new translations
skapur12 ab48b34
Add script to combine translated files by language
skapur12 8bff893
Add global build-translations command
skapur12 ac32380
Update comments and docs accordingly with changes
skapur12 7da21d9
Run merge-translations script on Azure DevOps path
skapur12 4609a68
Add localization for Batch Explorer web version
skapur12 9935ea7
Generate translations for Create Account buttons
skapur12 5488d42
Add basic i18n support for web package
skapur12 af4d629
Rename StandardLocalizer to BrowserLocalizer
skapur12 cb3f6e1
Add merge translations script for web and desktop
skapur12 07b7e09
Remove powershell merge translations script
skapur12 dbf75a1
Add localization support for desktop app
skapur12 8af9a55
Copy translations to web too and not just desktop
skapur12 20920ca
Add translations for playground buttons
skapur12 2ca588d
Gitignore generated localization files
skapur12 71a169c
Update localization docs with setup instructions
skapur12 2abf553
Add package translations to mergeTranslations
skapur12 33848fd
Optimize package file creation and fix unit test
skapur12 fe969ad
Update Electron app localization unit tests
skapur12 9530375
Address all feedback on PR
skapur12 eb1eb82
Fix desktop localizer, translation function, tests
skapur12 47e9245
Fix Prettier issue with account yml file
skapur12 92134c0
Update client translations unit test accordingly
skapur12 7972190
Add http-localizer unit test and minor fixes
skapur12 0307daa
Remove CustomGlobal and simplify navigator object
skapur12 cc8f35d
Add getLocale function to each localizer
skapur12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { app } from 'electron'; | ||
| import { Localizer } from "@batch/ui-common/lib/localization"; | ||
| import { AppTranslationsLoaderService } from "app/services"; | ||
|
|
||
| export class DesktopLocalizer implements Localizer { | ||
| constructor( | ||
| private translationsLoaderService: AppTranslationsLoaderService | ||
| ) { } | ||
|
|
||
| translate(message: string): string { | ||
| const translations = this.translationsLoaderService.translations; | ||
| if (!translations) { | ||
| throw new Error("Translation strings are not loaded: " + message); | ||
| } | ||
|
|
||
| const translation = translations.get(message); | ||
|
|
||
| if (translation != null) { | ||
| return translation; | ||
| } else { | ||
| return message; | ||
| } | ||
| } | ||
|
|
||
| getLocale(): string { | ||
| if (process.type === 'renderer') { | ||
| return navigator.language; | ||
| } else { | ||
| return app.getLocale(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,26 +1,24 @@ | ||
| # Building Localization on Local Machine | ||
|
|
||
| ## Building the English File | ||
| ## Building the English File (Any Machine) | ||
|
|
||
| To build the latest English translation resjson file from the YAML files: | ||
| To build the latest English translation file from the YAML files: | ||
|
|
||
| * Run `npm run build` to build translations for the entire repository | ||
| * Run `npm run build-translations` in any package directory (desktop, packages/*) to build translations for a specific package | ||
| * Run `npm run build-translations` | ||
|
|
||
| The output will be in `{packageName}/i18n/resources.resjson` | ||
| * `web/dev-server/resources/i18n/resources.en.json` contains web English strings (web + all packages) | ||
| * `desktop/resources/i18n/resources.en.json` contains desktop English strings (desktop + all packages) | ||
|
|
||
| ## Building Translations Files for Other Languages (Windows-Only) | ||
|
|
||
| To build the localization translations for all languages besides English: | ||
|
|
||
| * Follow the steps above first | ||
| * Follow the step above first (build the English file) | ||
| * Install the latest, recommended version of nuget.exe from <https://www.nuget.org/downloads> at C:\Users\{userName}, for instance. | ||
| * Navigate to the root of the repository | ||
| * Run `npm run loc:restore` to install all dependencies | ||
| * Run `npm run loc:build` to build the translations and move them to their correct directories | ||
| * If needed, run `npm run clean` to clear out all previously built translation files | ||
| * Run `npm run loc:build` to build the translations, move them to the package directories, and combine them altogether in one directory | ||
| * Run `npm run build-translations` to build the full, compiled translations for the web and desktop packages | ||
|
|
||
| The output will be in `{packageName}/resources/i18n` | ||
|
|
||
| * `{packageName}/resources/i18n/resjson` contains RESJSON translations | ||
| * `{packageName}/resources/i18n/json` contains JSON translations (RESJSON syntax and comments have been stripped out) | ||
| * `web/dev-server/resources/i18n` contains web translations (web + all packages) | ||
| * `desktop/resources/i18n` contains desktop translations (desktop + all packages) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| { | ||
| "lib.common.localizer.account": "Account", | ||
| "lib.common.localizer.resourceGroup": "Resource Group", | ||
| "lib.common.localizer.subscription": "Subscription" | ||
| "lib.common.form.validationError": "Value must be a boolean" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.