angular-i18n

How to use angular 9 $localize with plurals?

喜你入骨 提交于 2021-02-08 12:33:48
问题 Since Angular 9 we can use $localize`Hello ${name}:name:` For i18n in typescript code. This still has some limitations as the ng xi18n command does not detect the strings, but if these texts are added manually to the translation file it works. The $localize function is quite well documented in the JSDoc in the source, however it does not explain how to work with plurals. What I mean is something like this (pseudo-code): $localize`Hello {${count}, plural, =1 {reader} other {readers}}` Is this

How to serve different Angular locales during development using ng serve?

不羁的心 提交于 2020-07-18 22:12:26
问题 I'm developing an app in two different languages (fa/en) using Angular Internationalization (i18n). The target is to deploy the two different builds into sub-folders on the server (example.com/en/...) These builds are different not only in translation but also styles and layout directions are different. I can serve any of the localization (languages) like this "architect": { "build": { ... , "configurations": { ... }, "fa": { "localize": ["fa"], "baseHref": "/fa/" }, "en": { "localize": ["en"

How to serve different Angular locales during development using ng serve?

橙三吉。 提交于 2020-07-18 22:09:23
问题 I'm developing an app in two different languages (fa/en) using Angular Internationalization (i18n). The target is to deploy the two different builds into sub-folders on the server (example.com/en/...) These builds are different not only in translation but also styles and layout directions are different. I can serve any of the localization (languages) like this "architect": { "build": { ... , "configurations": { ... }, "fa": { "localize": ["fa"], "baseHref": "/fa/" }, "en": { "localize": ["en"

Translate strings inside Angular Typescript code

自作多情 提交于 2020-01-21 19:41:10
问题 Is it possible to translate strings inside the source code of a component in Angular6. F. e. window.confirm("HELP me"); I haven't found anything besides the normal translation for the HTML files (Angular Docs i18n). Thank you in advance 回答1: You can use https://github.com/ngx-translate/i18n-polyfill until Angular i18n get built-in support for it, probably around version 9. The author is working on Angular i18n, so I think it is safe to trust his expectation that it will be close to the future

angular 5 change locale dynamically for i18n

北战南征 提交于 2020-01-03 08:42:15
问题 I am trying to change locale dynamically to change i18n language. I have two files, the one with english values and the other one with french values. What I've tried for now is something like that : ngOnInit() { const localeName = localStorage.getItem('locale') || 'fr'; import(`@angular/common/locales/${localeName}.js`).then(locale => { registerLocaleData(locale.default); }); } but it gave me the following error : error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015

Updates to i18n translation files in Angular

两盒软妹~` 提交于 2019-12-23 09:29:27
问题 I am currently in the process of adding en locale to an Angular App we are using at my company. After some thinking we decided to go with the Angular 5+ native i18n support. From how I understand it however, everytime the translation file is generated with ng xi18n --outputPath src/locale/ --locale en a new file is created. This means, that every time a new i18n tag is added, the previous XLF file which already contains the old translations, needs to be merged with the new translations. This

Angular 5 internationalization

爱⌒轻易说出口 提交于 2019-12-17 15:29:58
问题 I'm building an application using the latest Angular5 and what I need is for a user to be able to switch languages. I've never had to implement this in an Angular2+ (actually I'm using Angular5). I need to set translations in two places: Component's template html - change labels to the specified language In code in the component.ts file - I may need to translate some strings that are built dynamically under particular conditions in the code I was looking at ngx-translation and it looks to do

angular-i18n work-around for translations in code?

淺唱寂寞╮ 提交于 2019-12-17 06:13:53
问题 We have to wait until Angular 6 for angular-i18n to support translations in code for error messages and such. For those that are using angular-i18n (instead of ngx-translate for instance) what are you doing in the meantime to handle translations in code? It occurs to me that if there are not many strings then a simple language service with methods to get translations by language code and an id would work, but I am interested in something more elegant and "angular". I do not know what the

Angular i18n translation for Dynamic component

半城伤御伤魂 提交于 2019-12-13 16:07:29
问题 I have been reading up a lot on Angular 2+ i18n and have been looking for the best way to try and build dynamic components. Problem: i18n cannot translate a variables text into an xlf file for dynamic i18n makes it hard to make dynamic components with text using i18n attribute Possible Solution: Even though we cannot use dynamic strings in variables for i18n to pick up when generating the language resource file we should still be able to create components and pass text to them. For the