-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ability to generate content.json in multiple languages
- Loading branch information
Showing
58 changed files
with
98 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/out-tsc | ||
|
||
# generated content | ||
content.json | ||
content.*.json | ||
|
||
# dependencies | ||
/node_modules | ||
|
This file contains 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,44 @@ | ||
# Translation Guide | ||
|
||
## Add languages | ||
|
||
The following tasks are required to add a new language. | ||
[See available code here](https://github.com/angular/angular/tree/master/packages/common/locales). | ||
|
||
- Copy production into the configurations section of angular.json to create production build settings for the language. | ||
- Add rewrites for the language to the `rewrites` of `firebase.json`. | ||
- Add languages to the languages in `xliffmerge.json` (And do `yarn i18n`). | ||
- Add languages to `langages`, an array of `tools/utils.ts` files. | ||
- Let's make build environment for language in `build:ssr` in scripts of package.json. | ||
- Register localeData of the language to be added to `app.module.ts` using `registerLocaleData()`. | ||
https://angular.io/guide/i18n#i18n-pipes | ||
- Add a language to the languages propety of `src/app/shared/footer/footer.component.ts`. | ||
- Make a target language directory by copying `en-US` in the content directory. And then run `yarn build-content`. | ||
|
||
Hooray! Now you can choose a new language. | ||
|
||
## Do translation | ||
|
||
There are two types of translation: translation of the application using angular i18n and translation of the main content composed of markdown. | ||
|
||
### Application translation | ||
|
||
Please read the [angular i18n](https://angular.io/guide/i18n) documentation once. | ||
|
||
Translate the app by editing `src/locale/messages.[language code].xlf`. | ||
It is difficult to edit xlf file manually, so use something like a tool. | ||
|
||
Tool Example: https://poedit.net/ | ||
|
||
### Translation of content | ||
|
||
Translation of content is editing files in the `content/[target lang]` directory. | ||
|
||
You don't have to make all the files at once. but when it's missing it will be displayed in original English. | ||
|
||
**Note:** If you set char such as `*` or `@` at the beginning of metadata such as `title:`, the translation will be broken. | ||
Use double-byte characters or devise a text. | ||
|
||
## Reflect the translated content | ||
|
||
See [CONTRIBUTING.md](https://github.com/angular-checklist/angular-checklist/blob/master/CONTRIBUTING.md). |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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 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 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,13 +1,19 @@ | ||
import { join } from 'path'; | ||
import { buildChecklist, dumpDataToDisk, printSuccess } from './utils'; | ||
import { buildChecklist, dumpDataToDisk, printSuccess, langages, localeEnUS, transrateDeepMerge } from './utils'; | ||
|
||
const CONTENT_FOLDER = join(__dirname, '../content'); | ||
const ASSET_FOLDER = join(__dirname, '../src/assets'); | ||
|
||
buildChecklist(CONTENT_FOLDER).then(checklist => { | ||
if (checklist) { | ||
dumpDataToDisk('content', checklist, ASSET_FOLDER); | ||
printSuccess('Content was successfully compiled', 'Done'); | ||
process.exit(0); | ||
} | ||
Promise.all( | ||
langages.map(async lang => { | ||
const checklist = await buildChecklist(join(CONTENT_FOLDER, lang)); | ||
const checklistEnUS = await buildChecklist(join(CONTENT_FOLDER, localeEnUS)); | ||
|
||
if (checklist && checklistEnUS) { | ||
dumpDataToDisk(`content.${lang}`, transrateDeepMerge(checklistEnUS, checklist), ASSET_FOLDER); | ||
} | ||
}) | ||
).then(() => { | ||
printSuccess('Content was successfully compiled', 'Done'); | ||
process.exit(0); | ||
}); |
This file contains 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