Skip to content

Support for a split of translations coming from library and from the App #570

Answered by ivanhofer
bn3t asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @bn3t,
since typesafe-i18n uses regular TypeScript files, you can manage your dictionaries however you want. You could split the stings out into multiple files like this:

/common/i18n/en.ts

export const common: BaseTranslation = {
	companyName: 'Best Company'
}

/lib/i18n/en.ts

export const lib: BaseTranslation = {
	login: {
	   	ctaLabel: 'Login',
		invalidCredentials: 'Username or password do not match any user on this system'
	}
}

/app/src/i18n/en/index.ts

const en: BaseTranslation = {
	...common,
	...lib,
   projectLabel: '{nr: number} Project{{s}}'
}

export default en

Or you can also have it's own instance per package. Then you would need to make sure to initialize the locale for …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bn3t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants