Aspnetzero 8.8 (Angular + .NET Core)
We create "public" users on the fly who have access to a limited set of features.
For these users, the default language (french) is ignored, even when we set it as a user setting before authenticating.
Here's the workflow :
var publicUser = Authorization.Users.User.CreateTenantAdminUser(AbpSession.TenantId.Value, $"{userName}@public.com");
this.processAuthenticateResult(result, 'publiclanding');
Problem : the language is English even though the tenant default language setting is set to french.
And we tried to override the default setting for the user as follows (in tokenAuthService, right before authenticating) :
_settingManager.ChangeSettingForUser(publicUser.ToUserIdentifier(), LocalizationSettingNames.DefaultLanguage, "fr");
but it doesn't work either.
From what I can read from this page : https://aspnetboilerplate.com/Pages/Documents/Localization#asp-net-core, the user setting should be preferred over other settings, right ?
My solution is to change the AppService method signature to return a JSON string. I then transform and parse that string when received in the frontend.
In order to make it work, I had to do the following :
This is tedious and it breaks the webAPI contract but I haven't found a better solution to optimize the size of the transferred JSON. If someone comes up with a better solution, please share.
Thanks
I think that since this JSON response is returned by the AppService, it should be handled first on the server side, shouldn't it ?
Where does the AppService format the returned object to JSON ?
I have an AppService method which returns a very large array of int? (nullable int).
Most values in this array are null.
Currently, when calling the method via Web api, the response array is formatted like this in JSON :
[null,null,null, ..., 3, 4, 8, 11, 12, null, null, null, ...]
In order to spare network bandwith, I want my array to be like this :
[,,, ..., 3, 4, 8, 11, 12,,,, ...]
Is it doable without bypassing the service-proxies JSON parsing functions ?
(Using Aspnetcore 7.2.3 with angular)
I see now. Thanks.
For further reference, two things are necessary to achieve what I need :
In the localization files, html must be enclosed in CDATA tags :
<text name="MyTextKey"><![CDATA[<span><b>MyText</b><br/>is formatted in the current language</span>]]></text>
In order for the html to be rendered on the client, assign it to the innerHtml of a span element :
<span [innerHtml]="l('MyTextKey')"></span>
And voilà :-)
Whether I call the l() function in my html template or in my javascript code will not make a difference, since the string values in my App-xx.xml can't have html tags.
So where do I store the html translations ? And how do I display them to the user ?
Said otherwise : I need to display very long formatted texts in several different languages. The texts are provided to me in a Word document, which I then convert to html (in order to keep the formatting). The conversion result is what I want to display (according to the current language). In different languages, the html tags will be set on different parts of the text, which makes it impossible to have an html template and a lot of strings to translate between the tags.
I'm sorry but I see nothing about including html in translated text strings ?
How can I format localized text in html ?
Example :
{{l('MyTextKey')}}
Would return (in English for instance) :
<span><b>MyText</b><br/>is formatted in the current language</span>
Which would render on screen :
MyText is formatted in the current language
We're using abp 7.2.3 with angular
Our application is pretty big (15MB) and we would like to reduce its size. One of the things we can do is to remove the biggest unused packages.
With webpack-bundle-analyzer, we determined that the following packages are quite big :
Q1. Is it necessary to keep both momentjs AND momentjs-min ? Q2. We'd like to include only locales we need. In order to do that, we tried moment-locales-webpack-plugin + ngx-build-plus but it doesn't work on our code (even on a freshly downloaded template). Any recommendation to make it work ? Our current workaround is to replace moment locale folder with a custom locale folder post build but it's not super clean. ~~Q3. Can we safely remove quill without breaking abp features ?~~ EDIT: I just found out that someone in the team needs the primeng editor, which is based on quill, so forget about this one. Q4. How can we adjust the Web.Host server log to know which request completed in how much time ? (example : "Request finished in xx ms (<REQUEST_NAME>)"). This would help us identify which backend requests need optimization.
Our project is on aspnetzero 7.2.3, with asp.net core & angular .net framework 4.6.1
Works fine. Thanks !