Skip to content
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

Change default language files path #281

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/translate-adapter-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ export async function parseOptions(options: {
if (options.base) {
i18nBases = options.base.map((p) => path.resolve(p));
} else {
const defaultPath = path.join(admin, "i18n", "en", "translations.json");
const defaultPath = path.join(admin, "i18n", "en.json");
i18nBases = [
defaultPath,
path.join(admin, "i18n", "en", "translations.json"),
path.join(admin, "src", "i18n", "en.json"),
].filter(existsSync);
if (i18nBases.length === 0) {
Expand Down
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Beispiel",
"Example 2": "Beispiel 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Example",
"Example 2": "Example 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Ejemplo",
"Example 2": "Ejemplo 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Exemple",
"Example 2": "Exemple 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Esempio",
"Example 2": "Esempio 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Voorbeeld",
"Example 2": "Voorbeeld 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/pl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Przykład",
"Example 2": "Przykład 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Exemplo",
"Example 2": "Exemplo 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "пример",
"Example 2": "пример 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/uk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Приклад",
"Example 2": "Приклад 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/expected/admin/i18n/zh-cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "例子",
"Example 2": "例子2"
}
13 changes: 13 additions & 0 deletions test/data/update-words-v2/expected/admin/words.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/data/update-words-v2/expected/io-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/de.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Beispiel",
"Example 2": "Beispiel 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Example",
"Example 2": "Example 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Ejemplo",
"Example 2": "Ejemplo 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Exemple",
"Example 2": "Exemple 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Esempio",
"Example 2": "Esempio 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/nl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Voorbeeld",
"Example 2": "Voorbeeld 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/pl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Przykład",
"Example 2": "Przykład 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/pt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Exemplo",
"Example 2": "Exemplo 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "пример",
"Example 2": "пример 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/uk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "Приклад",
"Example 2": "Приклад 2"
}
4 changes: 4 additions & 0 deletions test/data/update-words-v2/input/admin/i18n/zh-cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Example": "例子",
"Example 2": "例子2"
}
12 changes: 12 additions & 0 deletions test/data/update-words-v2/input/admin/words.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*global systemDictionary:true */
/*
+===================== DO NOT MODIFY ======================+
| This file was generated by translate-adapter, please use |
| `translate-adapter adminLanguages2words` to update it. |
+===================== DO NOT MODIFY ======================+
*/
'use strict';

systemDictionary = {
"Example": { "en": "Example", "de": "Beispiel", "ru": "пример", "pt": "Exemplo", "nl": "Voorbeeld", "fr": "Exemple", "it": "Esempio", "es": "Ejemplo", "pl": "Przykład", "zh-cn": "例子"},
};
1 change: 1 addition & 0 deletions test/data/update-words-v2/input/io-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 4 additions & 1 deletion test/translate-adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ describe("translate-adapter to-words", () => {
it("generates a new words.js if it doesn't exist", () => {
return runTranslation("no-words-yet", false, handleToWordsCommand);
});
it("updates words.js if new strings were added to the JSON files", () => {
it("updates words.js if new strings were added to the JSON files in i18n/<lang>/translations.json", () => {
return runTranslation("update-words", false, handleToWordsCommand);
});
it("updates words.js if new strings were added to the JSON files in i18n/<lang>.json", () => {
return runTranslation("update-words-v2", false, handleToWordsCommand);
});
});

describe("translate-adapter all", () => {
Expand Down