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

Common Translations for Multiple Projects #68

Open
tatems opened this issue Nov 18, 2020 · 0 comments
Open

Common Translations for Multiple Projects #68

tatems opened this issue Nov 18, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@tatems
Copy link

tatems commented Nov 18, 2020

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[ ] Performance issue
[x] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:

Current behavior

I'm currently working in an Nx monorepo with multiple applications and libraries. Some translations are common across multiple apps and libs (for example, Back, Next, our company name, etc).
It'd be very helpful if we could define a common/shared translation file with a key to denote the 'scope' that those translations fall under.

We are currently using merge-jsons-webpack-plugin with the @angular-builders/custom-webpack builder with the following example jsons:

app en.json

{
	"app": {"title": "My App"}
}

common en.json

{
	"common": {
		"next": "Next",
		"back": "Back",
		"companyName": "My Company
	}
}

However, when running the key manager, it updates the app json to be:

{
	"app": {"title": "My App"},
	"common": {
		"next": "Missing value for 'common.next'!",
		"back": "Missing value for 'common.back'!",
		"companyName": "Missing value for 'common.companyName'!
	}
}

At runtime, this isn't a problem since the jsons are merged and the app values are overwritten, but it's not ideal to have these values since it's not really representative of what's actually happening.

Expected behavior

Ideally, it'd be great to be able to define commonTranslations with a key and path value inside the config. For example:

module.exports = {
  langs: ['en', 'fr'],
  commonTranslations: {
    key: 'common',
    path: './common-i18n'
  }
};

Missing keys could then be inserted into the json files at the path instead of the application/lib file.

What is the motivation / use case for changing the behavior?

Our main motivation for this is to remove repetition for common localized phrases/text across a larger multi-project monorepo.

Environment


- Angular version: 10.0.8
- Node version: 12.16.1
- Platform:  Mac
@shaharkazaz shaharkazaz added the enhancement New feature or request label Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants