-
Notifications
You must be signed in to change notification settings - Fork 4
feature: mark primary strings #1833
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 10 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
3b0f785
chore: day one strings
ErikSin 5acf9ff
chore: more strings
ErikSin 93e81fd
chore: more string
ErikSin 4c2cbed
chore: more strings
ErikSin 99f85f2
Starts to marking primaary strings.
cimigree 7fa8e51
Messages with primary strings.
cimigree 124677b
Adds markers for the rest of the primary strings.
cimigree e6b4865
Rest of messages for the new primary ids.
cimigree 3efe893
Adds new extraction script to sort messages into primary and second f…
cimigree 3292ea8
Temporary patch for build translations to ignore file folders so CI c…
cimigree 7c62e1b
Comments out language test since it is broken for now as there is a k…
cimigree 6431d84
Removes comments about primary string.
cimigree ddd304e
Updates yaml for crowdin to include folder destinations.
cimigree 2e4c1ad
Removes english from german and french files.
cimigree 0e66acc
Removes English from translated files.
cimigree 6572ea8
Adds folders for all of the languages divided into primary and second…
cimigree b663878
Deletes unusued flat files. Adds folders for custom languages not alr…
cimigree fa683f9
Fixes some translations. Removes English. Adds delete an observation …
cimigree 590377a
Tries to match trailing new line to crowdin.
cimigree c39982d
Some french translations.
cimigree c6d2212
chore: update script
ErikSin e79cccb
New Crowdin updates (#1847)
digidem-bot d5bfab4
chore: update script to remove regional tag
ErikSin f6fdb83
chore: update languages.json
ErikSin 5c07601
chore: makes all translations available
ErikSin 844df33
chore: remove en.json
ErikSin 09fe2b2
chore: add coment explaining
ErikSin 1dd5797
Merge pull request #1849 from digidem/chore-update-translations-scrip…
ErikSin b96eaa8
Revert "Comments out language test since it is broken for now as ther…
ErikSin b0b2fcb
Merge pull request #1844 from digidem/chore/translations-new-structure
ErikSin 16b178f
Merge branch 'develop' into feature/mark-primary-strings
ErikSin cd75867
chore: 2 new translations
ErikSin 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,53 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * Extracts messages from source files and splits them into two files: | ||
| * messages/en-US/primary.json — strings marked as primary (id starts with "$1") | ||
| * messages/en-US/secondary.json — all other strings | ||
| * | ||
| * Primary strings are the ones that will be prioritized for translation in Crowdin. | ||
| */ | ||
|
|
||
| import path from 'node:path'; | ||
| import fs from 'node:fs'; | ||
| import {writeFile} from 'node:fs/promises'; | ||
| import {execSync} from 'node:child_process'; | ||
|
|
||
| const PROJECT_ROOT = new URL('../', import.meta.url).pathname; | ||
| const OUT_DIR = path.join(PROJECT_ROOT, 'messages', 'en-US'); | ||
| const TEMP_FILE = path.join(OUT_DIR, '_all.json'); | ||
| const PRIMARY_FILE = path.join(OUT_DIR, 'primary.json'); | ||
| const SECONDARY_FILE = path.join(OUT_DIR, 'secondary.json'); | ||
|
|
||
| fs.mkdirSync(OUT_DIR, {recursive: true}); | ||
|
|
||
| // Extract all messages into a temporary combined file using the crowdin format | ||
| execSync( | ||
| `npx formatjs extract 'src/frontend/**/*.{ts,tsx}' --ignore='**/*.d.ts' --format crowdin --out-file '${TEMP_FILE}'`, | ||
| {cwd: PROJECT_ROOT, stdio: 'inherit'}, | ||
| ); | ||
|
|
||
| const all = JSON.parse(fs.readFileSync(TEMP_FILE, 'utf8')); | ||
|
|
||
| const primary = {}; | ||
| const secondary = {}; | ||
|
|
||
| for (const [key, value] of Object.entries(all)) { | ||
| if (key.startsWith('$1')) { | ||
| primary[key] = value; | ||
| } else { | ||
| secondary[key] = value; | ||
| } | ||
| } | ||
|
|
||
| fs.unlinkSync(TEMP_FILE); | ||
|
|
||
| await writeFile(PRIMARY_FILE, JSON.stringify(primary, null, 2)); | ||
| await writeFile(SECONDARY_FILE, JSON.stringify(secondary, null, 2)); | ||
|
|
||
| console.log( | ||
| `Extracted ${Object.keys(primary).length} primary strings → messages/en-US/primary.json`, | ||
| ); | ||
| console.log( | ||
| `Extracted ${Object.keys(secondary).length} secondary strings → messages/en-US/secondary.json`, | ||
| ); |
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
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
Oops, something went wrong.
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.
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.
we should delete this file
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.
The build-translations.mjs script still reads from the messages/ folder and en.json is in there. So if we delete it now, the app's English strings would break until step 5. Are you sure we want to do that?