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

How to manage missing keys when using @rxweb/translate? #516

Open
RushiTheSharma opened this issue Sep 8, 2021 · 8 comments
Open

How to manage missing keys when using @rxweb/translate? #516

RushiTheSharma opened this issue Sep 8, 2021 · 8 comments

Comments

@RushiTheSharma
Copy link

Describe the problem statement?

The expected solution you would like

Url

Package version

@rxweb/

@ajayojha
Copy link
Member

ajayojha commented Sep 8, 2021

@RushiTheSharma Please share a little bit more information about where and what you wanna manage

@RushiTheSharma
Copy link
Author

RushiTheSharma commented Sep 8, 2021

I am using @rxweb/translate and import module as bellow

RxTranslateModule.forRoot({
cacheLanguageWiseObject:true,
globalFilePath:"assets/i18n/{{language-code}}/global.{{language-code}}.json",
filePath:"assets/i18n/{{language-code}}/{{translation-name}}.{{language-code}}.json"
})

for example, there is JSON file for language support as bellow

global.json
{
"username":"Username",
"age":"Age"
}

Now I am using this file for load label in HTML file like bellow

@translate({translationName:'global'}) global: any;

'

{{global.username}}
'
'
{{global.password}}
'

but in the JSON file there is no "password" key is present and that's why when we translate a language it is giving errors and not loading labels. How to load default string if a particular key is not present in a language JSON file?

Also what if a particular language JSON file is not present? How to handle it?

@RushiTheSharma
Copy link
Author

Hello, Can I get a response?

@ajayojha
Copy link
Member

ajayojha commented Sep 9, 2021

@RushiTheSharma As such, there is no feature available where we can set the default value if the property is missing and we are not exposing any class which acknowledges based upon the request fail.

I am sure both features must be in the package, I will add and release the package soon.

@RushiTheSharma
Copy link
Author

ok, thank you for responding.
When can I expect this change in the next release? Or you can notify here when the release is done.

@ajayojha
Copy link
Member

ajayojha commented Sep 9, 2021

Before tomorrow's EOD, I will update here once I release the package.

@RushiTheSharma
Copy link
Author

ok, thank you.

@ajayojha
Copy link
Member

@RushiTheSharma Just to update you, I tried to implement the missing key feature but that's not possible because the package is providing a class object instead of calling a method by passing the multilingual key.

Regarding the missing file, I am drafting the feature document, will update it here once I release the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants