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

Feat / improve generate translations script #482

Merged
merged 1 commit into from
Jun 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
git config --global user.email '[email protected]'
git fetch origin ${{ github.ref_name }}
git merge origin/${{ github.ref_name }}
yarn && yarn i18next
yarn && yarn workspace @jwp/ott-web run i18next
env:
GITHUB_TOKEN: ${{ secrets.ACTION_TOKEN }}

Expand Down
28 changes: 0 additions & 28 deletions i18next-parser.config.js

This file was deleted.

1 change: 1 addition & 0 deletions knip.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const config: KnipConfig = {
'babel-plugin-transform-typescript-metadata', // Used to build with decorators for ioc resolution
'core-js', // Conditionally imported at build time
'eslint-plugin-codeceptjs', // Used by apps/web/test-e2e/.eslintrc.cjs
'i18next-parser',
'luxon', // Used in tests
'playwright', // Used in test configs
'sharp', // Requirement for @vite-pwa/assets-generator
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
"format:eslint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\" --fix",
"format:prettier": "prettier --write \"{**/*,*}.{js,ts,jsx,tsx}\"",
"format:stylelint": "stylelint --fix '**/*.{css,scss}'",
"i18next": "i18next 'platforms/*/src/**/*.{ts,tsx}' 'packages/*/src/**/*.{ts,tsx}' && node ./scripts/i18next/generate.js",
"i18next-diff": "npx ts-node ./scripts/i18next/diff-translations",
"i18next-update": "npx ts-node ./scripts/i18next/update-translations.ts && yarn i18next",
"i18next-update": "npx ts-node ./scripts/i18next/update-translations.ts && yarn workspace @jwp/ott-web run i18next",
"lint": "run-p -c lint:*",
"lint:eslint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\"",
"lint:prettier": "prettier --check \"{**/*,*}.{js,ts,jsx,tsx}\"",
Expand All @@ -43,7 +42,7 @@
"csv-parse": "^5.4.0",
"eslint": "^8.57.0",
"husky": "^6.0.0",
"i18next-parser": "^8.0.0",
"i18next-parser-workspaces": "^0.2.0",
"knip": "^5.0.3",
"lint-staged": "^15.1.0",
"npm-run-all": "^4.1.5",
Expand Down
30 changes: 30 additions & 0 deletions platforms/web/i18next-parser.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { readdirSync } = require('fs');
const { join } = require('path');

// i18next runs in the workspace root, so we need to make sure the locales path is correct
const localesPath = join(__dirname, '/public/locales');
const localesEntries = readdirSync(localesPath, { withFileTypes: true });
const locales = localesEntries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);

module.exports = {
contextSeparator: '_',
createOldCatalogs: true,
defaultNamespace: 'common',
defaultValue: '',
indentation: 2,
keepRemoved: false,
keySeparator: '.',
lexers: {
mjs: ['JavascriptLexer'],
js: ['JavascriptLexer'],
ts: ['JavascriptLexer'],
jsx: ['JsxLexer'],
tsx: ['JsxLexer'],
default: ['JavascriptLexer'],
},
lineEnding: 'auto',
locales,
namespaceSeparator: ':',
output: join(localesPath, '$LOCALE/$NAMESPACE.json'),
sort: true,
};
18 changes: 9 additions & 9 deletions platforms/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"codecept:desktop": "cd test-e2e && rm -rf \"./output/desktop\" && codeceptjs run-workers --suites ${WORKER_COUNT:=8} --config ./codecept.desktop.cjs",
"codecept:mobile": "cd test-e2e && rm -rf \"./output/mobile\" && codeceptjs run-workers --suites ${WORKER_COUNT:=8} --config ./codecept.mobile.cjs",
"generate-pwa-assets": "pwa-assets-generator",
"i18next": "i18next-workspaces parse ./ && i18next-workspaces namespaces ./ src/i18n/resources.ts",
"lint:ts": "tsc --pretty --noEmit -p ./ && tsc --pretty --noEmit -p ./test-e2e",
"serve-report:desktop": "cd test-e2e && allure serve \"./output/desktop\"",
"serve-report:mobile": "cd test-e2e && allure serve \"./output/mobile\"",
Expand All @@ -26,6 +27,11 @@
},
"dependencies": {
"@codeceptjs/allure-legacy": "^1.0.2",
"@jwp/ott-common": "*",
"@jwp/ott-hooks-react": "*",
"@jwp/ott-testing": "*",
"@jwp/ott-theme": "*",
"@jwp/ott-ui-react": "*",
"i18next": "^22.4.15",
"i18next-browser-languagedetector": "^6.1.1",
"i18next-http-backend": "^2.2.0",
Expand Down Expand Up @@ -56,11 +62,14 @@
"babel-plugin-transform-typescript-metadata": "^0.3.2",
"codeceptjs": "3.5.5",
"core-js": "^3.37.0",
"eslint-config-jwp": "*",
"eslint-plugin-codeceptjs": "^1.3.0",
"i18next-parser": "^8.13.0",
"jsdom": "^22.1.0",
"luxon": "^3.2.1",
"playwright": "^1.38.1",
"postcss": "^8.4.31",
"postcss-config-jwp": "*",
"react-app-polyfill": "^3.0.0",
"reflect-metadata": "^0.1.13",
"sass": "^1.49.10",
Expand All @@ -85,14 +94,5 @@
"gh-pages": "^3.2.3",
"lighthouse": "^9.6.7",
"sharp": "^0.33.2"
},
"peerDependencies": {
"@jwp/ott-common": "*",
"@jwp/ott-hooks-react": "*",
"@jwp/ott-testing": "*",
"@jwp/ott-theme": "*",
"@jwp/ott-ui-react": "*",
"eslint-config-jwp": "*",
"postcss-config-jwp": "*"
}
}
1 change: 0 additions & 1 deletion platforms/web/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"home": "Home",
"live": "LIVE",
"now": "Now",
"optional": "(Optional)",
"play_item": "Play {{title}}",
"scheduled": "Scheduled",
"sign_in": "Sign in",
Expand Down
2 changes: 1 addition & 1 deletion platforms/web/public/locales/en/country.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@
"ye": "Yemen",
"zm": "Zambia",
"zw": "Zimbabwe"
}
}
2 changes: 1 addition & 1 deletion platforms/web/public/locales/en/us_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"wv": "West Virginia",
"wi": "Wisconsin",
"wy": "Wyoming"
}
}
18 changes: 3 additions & 15 deletions platforms/web/public/locales/en/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"add_password": "Add password",
"add_password_error": "Failed to proceed to the Add Password screen. Please try again.",
"add_password_modal_text": "We sent instructions to {{email}} on how to add a password. If you don’t receive the email within a few minutes, check your spam folder or",
"add_profile": "Add profile",
"cancel": "Cancel",
"confirm_password": "Confirm password",
"continue": "Continue",
Expand Down Expand Up @@ -51,7 +50,6 @@
"export_data_title": "Export account data",
"firstname": "First name",
"lastname": "Last name",
"manage_profiles": "Manage profiles",
"other_registration_details": "Other registration details",
"password": "Password",
"proceed_to_adding_a_password": "Proceed to adding a password",
Expand All @@ -62,8 +60,7 @@
"terms_and_tracking": "Legal & Marketing",
"update_consents": "Update consents",
"update_success": "Your {{section}} has been successfully updated.",
"view_password": "View password",
"who_is_watching": "Who’s watching?"
"view_password": "View password"
},
"favorites": {
"clear": "Clear favorites",
Expand All @@ -77,13 +74,11 @@
},
"nav": {
"account": "Account",
"add_profile": "Add new profile",
"favorites": "Favorites",
"logout": "Log out",
"payments": "Payments",
"profile": "Profile",
"settings": "Settings",
"switch_profiles": "Switch profiles"
"settings": "Settings"
},
"payment": {
"access_granted": "access granted",
Expand Down Expand Up @@ -132,23 +127,17 @@
"profile": {
"adult": "Adult",
"avatar": "Avatar",
"back_to_profiles": "Back to profiles",
"content_rating": "Content rating",
"create_message": "Create your profile",
"created_message": "You successfully created your profile. Now go and watch some awesome content and assemble your own personal collection of favorites.",
"created_title": "You’ve created your profile",
"delete": "Delete profile",
"delete_confirmation": "Are you sure you want to delete your profile? You will lose all you watch history and settings connected to this profile.",
"delete_description": "Permanently delete your profile along with all of your watch history and favorites.",
"delete_main": "The main profile cannot be deleted because it’s linked to your account's watch history and favorites.",
"description": "Profiles allow you to watch content and assemble your own personal collection of favorites.",
"done": "Done",
"edit": "Edit profile",
"form_error": "Something went wrong. Please try again later.",
"info": "Profile info",
"kids": "Kids",
"name": "User name",
"no_one_watching": "There’s no one watching.",
"validation": {
"name": {
"already_exists": "This profile name is already taken. Please choose another one.",
Expand All @@ -157,7 +146,6 @@
"too_long": "Please limit your profile name to {{charactersCount}} characters or fewer.",
"too_short": "Please enter at least {{charactersCount}} characters."
}
},
"watch_now": "Watch now"
}
}
}
1 change: 0 additions & 1 deletion platforms/web/public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"home": "Inicio",
"live": "EN VIVO",
"now": "Ahora",
"optional": "(Opcional)",
"play_item": "Reproducir {{title}}",
"scheduled": "Programada",
"sign_in": "Iniciar sesión",
Expand Down
2 changes: 1 addition & 1 deletion platforms/web/public/locales/es/country.json
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@
"ye": "Yemen",
"zm": "Zambia",
"zw": "Zimbabue"
}
}
2 changes: 1 addition & 1 deletion platforms/web/public/locales/es/us_state.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@
"wv": "Virginia Occidental",
"wi": "Wisconsin",
"wy": "Wyoming"
}
}
18 changes: 3 additions & 15 deletions platforms/web/public/locales/es/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"add_password": "Agregar contraseña",
"add_password_error": "No se pudo pasar a la pantalla Agregar contraseña. Inténtalo de nuevo.",
"add_password_modal_text": "Enviamos instrucciones a {{email}} sobre cómo agregar una contraseña. Si no recibes el correo electrónico en unos minutos, revisa tu carpeta de spam o",
"add_profile": "Añadir perfil",
"cancel": "Cancelar",
"confirm_password": "Confirmar contraseña",
"continue": "Continuar",
Expand Down Expand Up @@ -51,7 +50,6 @@
"export_data_title": "Por favor revise su correo electrónico.",
"firstname": "Nombre",
"lastname": "Apellido",
"manage_profiles": "Administrar perfiles",
"other_registration_details": "Otros detalles de registro",
"password": "Contraseña",
"proceed_to_adding_a_password": "Proceda a agregar una contraseña",
Expand All @@ -62,8 +60,7 @@
"terms_and_tracking": "Jurídico y marketing",
"update_consents": "Actualizar consentimientos",
"update_success": "Tu {{section}} ha sido actualizado con éxito.",
"view_password": "Ver contraseña",
"who_is_watching": "¿Quién está mirando?"
"view_password": "Ver contraseña"
},
"favorites": {
"clear": "Borrar favoritos",
Expand All @@ -77,13 +74,11 @@
},
"nav": {
"account": "Cuenta",
"add_profile": "Añade un nuevo perfil",
"favorites": "Favoritos",
"logout": "Cerrar sesión",
"payments": "Pagos",
"profile": "Perfil",
"settings": "Ajustes",
"switch_profiles": "Cambiar de perfil"
"settings": "Ajustes"
},
"payment": {
"access_granted": "acceso concedido",
Expand Down Expand Up @@ -133,23 +128,17 @@
"profile": {
"adult": "Adultos",
"avatar": "Avatar",
"back_to_profiles": "Volver a perfiles",
"content_rating": "Puntuación del contenido",
"create_message": "Crea tu perfil",
"created_message": "Creaste exitosamente tu perfil. Ahora ve y mira contenido increíble y reúne tu propia colección personal de favoritos.",
"created_title": "Has creado tu perfil",
"delete": "Eliminar perfil",
"delete_confirmation": "¿Estás seguro que quieres eliminar tu perfil? Perderás todo tu historial y ajustes en este perfil.",
"delete_description": "Borrar permentemente el perfil junto con el contenido de tu historial y favoritos.",
"delete_main": "El perfil principal no puede ser borrado debido a que está ligado al historial de tu cuenta y tus favoritos.",
"description": "Los perfiles te permiten ver el contenido y organizar tu colección de favoritos.",
"done": "Hecho",
"edit": "Editar perfil",
"form_error": "Algo salió mal. Intenta de nuevo más tarde",
"info": "Información del perfil",
"kids": "Niños",
"name": "Nombre del usuario",
"no_one_watching": "No hay nadie mirando.",
"validation": {
"name": {
"already_exists": "Este nombre de perfil ya está en uso. Por favor elije otro.",
Expand All @@ -158,7 +147,6 @@
"too_long": "Por favor, limite el nombre de su perfil a {{charactersCount}} caracteres o menos.",
"too_short": "Por favor introduzca al menos {{charactersCount}} caracteres."
}
},
"watch_now": "Ver ahora"
}
}
}
4 changes: 2 additions & 2 deletions platforms/web/src/i18n/resources.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated, do not modify manually.
// Run `$ yarn i18next` to update this file
// This file is generated by i18next-parser-workspaces, do not modify manually.
// Run `$ npx i18next-workspaces` to update this file

export const NAMESPACES = ['account', 'common', 'country', 'demo', 'epg', 'error', 'menu', 'search', 'us_state', 'user', 'video'];
32 changes: 0 additions & 32 deletions scripts/i18next/generate.js

This file was deleted.

Loading
Loading