[WEB-4810] feat: migrate to tsdown from tsup (#7679)
* feat: migrat to tsdown to tsup * fix: build scripts * fix: lock file fixes * fix: adding build process to i18n and propel packages * fix: lint warning * chore: update services module entry points * fix: lock file * fix: lock file * fix: remove tsc from build * fix: tsdown configs * fix: remove tsc step from build process --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Aaron Reisman <aaron.reisman@plane.so>
This commit is contained in:
parent
91f0228b5f
commit
b99ddc24e7
38 changed files with 663 additions and 539 deletions
|
|
@ -2,3 +2,5 @@ export * from "./constants";
|
|||
export * from "./context";
|
||||
export * from "./hooks";
|
||||
export * from "./types";
|
||||
export * from "./store";
|
||||
export * from "./locales";
|
||||
|
|
|
|||
105
packages/i18n/src/locales/index.ts
Normal file
105
packages/i18n/src/locales/index.ts
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
// Export all locale files to make them accessible from the package root
|
||||
export { default as enCore } from "./en/core.json";
|
||||
export { default as enTranslations } from "./en/translations.json";
|
||||
export { default as enAccessibility } from "./en/accessibility.json";
|
||||
export { default as enEditor } from "./en/editor.json";
|
||||
|
||||
// Export locale data for all supported languages
|
||||
export const locales = {
|
||||
en: {
|
||||
core: () => import("./en/core.json"),
|
||||
translations: () => import("./en/translations.json"),
|
||||
accessibility: () => import("./en/accessibility.json"),
|
||||
editor: () => import("./en/editor.json"),
|
||||
},
|
||||
fr: {
|
||||
translations: () => import("./fr/translations.json"),
|
||||
accessibility: () => import("./fr/accessibility.json"),
|
||||
editor: () => import("./fr/editor.json"),
|
||||
},
|
||||
es: {
|
||||
translations: () => import("./es/translations.json"),
|
||||
accessibility: () => import("./es/accessibility.json"),
|
||||
editor: () => import("./es/editor.json"),
|
||||
},
|
||||
ja: {
|
||||
translations: () => import("./ja/translations.json"),
|
||||
accessibility: () => import("./ja/accessibility.json"),
|
||||
editor: () => import("./ja/editor.json"),
|
||||
},
|
||||
"zh-CN": {
|
||||
translations: () => import("./zh-CN/translations.json"),
|
||||
accessibility: () => import("./zh-CN/accessibility.json"),
|
||||
editor: () => import("./zh-CN/editor.json"),
|
||||
},
|
||||
"zh-TW": {
|
||||
translations: () => import("./zh-TW/translations.json"),
|
||||
accessibility: () => import("./zh-TW/accessibility.json"),
|
||||
editor: () => import("./zh-TW/editor.json"),
|
||||
},
|
||||
ru: {
|
||||
translations: () => import("./ru/translations.json"),
|
||||
accessibility: () => import("./ru/accessibility.json"),
|
||||
editor: () => import("./ru/editor.json"),
|
||||
},
|
||||
it: {
|
||||
translations: () => import("./it/translations.json"),
|
||||
accessibility: () => import("./it/accessibility.json"),
|
||||
editor: () => import("./it/editor.json"),
|
||||
},
|
||||
cs: {
|
||||
translations: () => import("./cs/translations.json"),
|
||||
accessibility: () => import("./cs/accessibility.json"),
|
||||
editor: () => import("./cs/editor.json"),
|
||||
},
|
||||
sk: {
|
||||
translations: () => import("./sk/translations.json"),
|
||||
accessibility: () => import("./sk/accessibility.json"),
|
||||
editor: () => import("./sk/editor.json"),
|
||||
},
|
||||
de: {
|
||||
translations: () => import("./de/translations.json"),
|
||||
accessibility: () => import("./de/accessibility.json"),
|
||||
editor: () => import("./de/editor.json"),
|
||||
},
|
||||
ua: {
|
||||
translations: () => import("./ua/translations.json"),
|
||||
accessibility: () => import("./ua/accessibility.json"),
|
||||
editor: () => import("./ua/editor.json"),
|
||||
},
|
||||
pl: {
|
||||
translations: () => import("./pl/translations.json"),
|
||||
accessibility: () => import("./pl/accessibility.json"),
|
||||
editor: () => import("./pl/editor.json"),
|
||||
},
|
||||
ko: {
|
||||
translations: () => import("./ko/translations.json"),
|
||||
accessibility: () => import("./ko/accessibility.json"),
|
||||
editor: () => import("./ko/editor.json"),
|
||||
},
|
||||
"pt-BR": {
|
||||
translations: () => import("./pt-BR/translations.json"),
|
||||
accessibility: () => import("./pt-BR/accessibility.json"),
|
||||
editor: () => import("./pt-BR/editor.json"),
|
||||
},
|
||||
id: {
|
||||
translations: () => import("./id/translations.json"),
|
||||
accessibility: () => import("./id/accessibility.json"),
|
||||
editor: () => import("./id/editor.json"),
|
||||
},
|
||||
ro: {
|
||||
translations: () => import("./ro/translations.json"),
|
||||
accessibility: () => import("./ro/accessibility.json"),
|
||||
editor: () => import("./ro/editor.json"),
|
||||
},
|
||||
"vi-VN": {
|
||||
translations: () => import("./vi-VN/translations.json"),
|
||||
accessibility: () => import("./vi-VN/accessibility.json"),
|
||||
editor: () => import("./vi-VN/editor.json"),
|
||||
},
|
||||
"tr-TR": {
|
||||
translations: () => import("./tr-TR/translations.json"),
|
||||
accessibility: () => import("./tr-TR/accessibility.json"),
|
||||
editor: () => import("./tr-TR/editor.json"),
|
||||
},
|
||||
};
|
||||
|
|
@ -5,7 +5,7 @@ import { makeAutoObservable, runInAction } from "mobx";
|
|||
// constants
|
||||
import { FALLBACK_LANGUAGE, SUPPORTED_LANGUAGES, LANGUAGE_STORAGE_KEY, ETranslationFiles } from "../constants";
|
||||
// core translations imports
|
||||
import coreEn from "../locales/en/core.json";
|
||||
import { enCore, locales } from "../locales";
|
||||
// types
|
||||
import { TLanguage, ILanguageOption, ITranslations } from "../types";
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ import { TLanguage, ILanguageOption, ITranslations } from "../types";
|
|||
export class TranslationStore {
|
||||
// Core translations that are always loaded
|
||||
private coreTranslations: ITranslations = {
|
||||
en: coreEn,
|
||||
en: enCore,
|
||||
};
|
||||
// List of translations for each language
|
||||
private translations: ITranslations = {};
|
||||
|
|
@ -138,10 +138,24 @@ export class TranslationStore {
|
|||
*/
|
||||
private async importAndMergeFiles(language: TLanguage, files: string[]) {
|
||||
try {
|
||||
const importPromises = files.map((file) => import(`../locales/${language}/${file}.json`));
|
||||
const localeData = locales[language as keyof typeof locales];
|
||||
if (!localeData) {
|
||||
throw new Error(`Locale data not found for language: ${language}`);
|
||||
}
|
||||
|
||||
// Filter out files that don't exist for this language
|
||||
const availableFiles = files.filter((file) => {
|
||||
const fileKey = file as keyof typeof localeData;
|
||||
return fileKey in localeData;
|
||||
});
|
||||
|
||||
const importPromises = availableFiles.map((file) => {
|
||||
const fileKey = file as keyof typeof localeData;
|
||||
return localeData[fileKey]();
|
||||
});
|
||||
|
||||
const modules = await Promise.all(importPromises);
|
||||
const merged = modules.reduce((acc, module) => merge(acc, module.default), {});
|
||||
const merged = modules.reduce((acc: any, module: any) => merge(acc, module.default), {});
|
||||
return { default: merged };
|
||||
} catch (error) {
|
||||
throw new Error(`Failed to import and merge files for ${language}: ${error}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue