-
Notifications
You must be signed in to change notification settings - Fork 67
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
feat: ability to generate content.json in multiple languages #48
Open
MSakamaki
wants to merge
3
commits into
typebytes:master
Choose a base branch
from
MSakamaki:i18n-step1-content-multiple-languages
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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,36 @@ | ||
# 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). | ||
|
||
- Add word transration file in `src/assets/i18n/[lang-code].json`. | ||
- Add languages to `langages`, an array of `tools/utils.ts` files. | ||
- Register langage code of the language to be added to `translocoConfig()` in `src/app/app.module.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 [transloco](https://netbasal.gitbook.io/transloco/) and translation of the main content composed of markdown. | ||
|
||
### Application translation | ||
|
||
Please read the [transloco](https://netbasal.gitbook.io/transloco/) documentation once. | ||
|
||
Translate the app by editing `src/assets/i18n/[lang-code].json`. | ||
|
||
### Translation of content | ||
|
||
Translation of content is editing files in the `content/[lang-code]` 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
transration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maartentibau, I fixed it! (and unknown space)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @maartentibau for keeping an eye on this too! 🙏