-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
After updating to 1.0.2, XML approach could not get value for neutral language (en culture). #19
Comments
Hi @mohamedryan , I'm fine thanks, hope you are fine too 😊. The final update So instead of using coded key strings in the views, you have to use a clear texts of the source translation culture inside the views, e.g.: Assume we have a view with one title and one paragraph, and we have defined <!-- This will not be localized if current culture in "en" -->
<!-- but will be localized for all other cultures -->
<h1 localize-content>Covid19TipsTitle</h1>
<p localize-content>Covid19TipsDesc</p> <!-- This will be localized for all cultures other than "en" -->
<!-- since it is a clear "en" text, no need for localization if current culture is "en" -->
<h1 localize-content>COVID-19 Prevention Tips</h1>
<p localize-content>
Adhere to the rules of spatial distancing...
</p> You can use any culture in the views, but you have to set the services.AddRazorPages()
.AddXLocalizer<LocSource, MyTranslateService>(ops =>
{
// ...
ops.TranslateFromCulture = "en";
}); Notice: if you don't set a value for |
Just re-evaluated your issue, I think it could be a use case where you need to use codes instead of texts inside views. So, I will add an option to bypass or include source translation culture in localization. It will look something like below: services.AddRazorPages()
.AddXLocalizer<LocSource, MyTranslateService>(ops =>
{
// ...
// true: don't localize if current culture == source culture
// false: always localize
ops.BypassSourceCulture = false;
}); By default it will be I will provide this option in the upcoming update... |
@LazZiya , I believe it will be an important option, as for sure there are some users who used a lot of coded keys, so this update will require him to do many changes in his code. but for me, I don't have too many coded keys, so I will go with the clear texts for now. Thanks and Regards. 😄 |
Fix is now available in XLocalizer v1.0.3 (for XML and RESX resource types). And XLocalizer.DB v1.0.2 (for DB resource type). Both can be downloaded from nuget: BR; |
Explanation to use the fix: services.AddRazorPages()
.AddXLocalizer<LocSource, MyMemoryTranslateService>(ops =>
{
// ...
ops.LocalizeDefaultCulture = true;
});
} The value of Here is a sample auto added key-value when source-culture and target-cultures are the same: <data isActive="false">
<key>Welcome</key>
<value>Welcome</value>
<comment>Created by XLocalizer</comment>
</data> Limitation:Since online translation services requires two different languages to translate, so online translation will not work when the source and target cultures are same. Anyhow, Hope this will help :) |
Hi @LazZiya ,
Hope you are doing well,
This issue happened after I updated the localizer version to 1.0.2.
I'm using the XML approach with autoKey and translate options.
Before the translation work perfect for both languages (Arabic, English).
LocSource.ar.xml
LocSource.en.xml
And the value was getting correctly.
After updating, only the key name is getting with 'en' culture, the Arabic is working fine.
English Culture
Arabic Culture
I returned to the previous version until the issue is fixed.
I hope this issue is clear to you. And Many Thanks to you.
The text was updated successfully, but these errors were encountered: