[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
|
|
@ -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