Hi, i'm a newbie with boilerplate, and i need some help. I download the template with module zero and i want to change the default language to Indonesian (id-ID). I added the language source to the database (AbpLanguage) and then I also registered my dictionary to the database (AbpLanguageTexts) and XML file (Core.Localization.Source). Then, I change the default setting on the database from "en" to "id-ID". It works on some browser, some of them still show the default "en" language. In desperation, i remove all others language on the database and finally the localization works on all browser.
In the middle of development, when i have to handle exception using "CheckErrors" method in handling IdentityResult, i found that the localization not working on my exceptionHandling. Instead it returns exception message "[Can not delete admin user]". I also tried to adding "[Can not delete admin user]" as a Key for my Localization dictionary but not working.
While debugging, I experimented a little by re-adding the "en" dictionary to the database. I tried to reproduce the bug, but instead it showing exception message "Can not delete user admin since this is the default admin user" without brackets. Which means, the localization works fine with "en" without we have to describe the key on the database.
My point is how can we configure dictionary for localization for exception handling? Pardon me for the bad English and some technical terms
4 Answer(s)
-
0
Hi,
I suppose I understood your problem.
Browser problem probably related to browser's caching (because ABP can not do different based on browsers). Just disable caching for browsers.
Internal error messages are defined in nuget packages (in another localization source). You can extend localization sources in order to add new languages.
The exception message you got is defined here: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/dev/src/Abp.Zero/Zero/Localization/Source/AbpZero.xml#L31">https://github.com/aspnetboilerplate/mo ... ro.xml#L31</a>
Localization source name is "AbpZero". You can extend it as described here: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Localization#DocExtending">http://www.aspnetboilerplate.com/Pages/ ... cExtending</a>
But I suggest you a better way: Just contribute Indonesian to the module-zero repository just like other people did: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/tree/dev/src/Abp.Zero/Zero/Localization/Source">https://github.com/aspnetboilerplate/mo ... ion/Source</a> (if you have trouble on Github contribution, just send XML to me, I will add) Thus, it will work in the next release of Abp.Zero package.
-
0
Thanks a lot, The code is working fine now. Of Course, I'll be gladly send you the Indonesian XML once it finished. I hope it could helps.
Also after reading the documentation, I still don't get how to use CheckErrors() method. how can I use this line as validation? <text name="Identity.DuplicateName" value="Name {0} is already taken." />
also here is my code public async Task<IdentityResult> CreateAsync(GuestCategory input) { IdentityResult _return = new IdentityResult(); try { if (_guestCategoryRepository.Count(i => i.Name == input.Name) == 0) { await _guestCategoryRepository.InsertAsync(input); _return = IdentityResult.Success; } else { _return = IdentityResult.Failed("Identity.DuplicateName"); } } catch (Exception ex) { _return = IdentityResult.Failed(ex.Message); } return _return; }
I think I'm using IdentityResult wrong here, pls help Thanks
-
0
Hi,
You can use it like this. After calling CreateAsync call CheckErrors
(await CreateAsync(user)).CheckErrors();
-
0
Thank you for your reply. I'm afraid that it's not the answer I seek, but the main problem is already resolved. I guest i just have to post a new one instead. Thanks