angular-localization | angularjs localization | Internationalization library
kandi X-RAY | angular-localization Summary
kandi X-RAY | angular-localization Summary
A localization module for AngularJS complete with core service and accompanying filter, directives etc.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Load a bundle
- Utility function to extract a localized string
- Gets the preferred browser language .
- Load a locale bundle .
- replace all substitutions in a string
- Set the current locale
- Wait for the bundle to be loaded
- Fetches a bundle
- Returns the language for the specified language .
- Get key .
angular-localization Key Features
angular-localization Examples and Code Snippets
Community Discussions
Trending Discussions on angular-localization
QUESTION
I am trying to add the automatic translation for primeNg so I do not need to manually translate each message to the language I wish to use. I am using Angular 11 so I followed the docs for V11 on localization, using ngx-translate.
My issue is that the primeNg example uses English, and I seem to be missing something to actually make it work.
This is what I have so far:
In my app.module.ts, as per ngx-translate explainations:
...ANSWER
Answered 2021-May-30 at 12:59Working Demo Stackblitz Link.
In your code your translate()
method is not calling. Thats why your json file is not loading inside your component.
QUESTION
I am trying to set up an Angular 2 project with i18n. Followed the tutorial here using Transloco and all works great. However, when I run the unit tests I get this error and I cant find anything online about it. I am defiantly missing something but I dont know what. Any help would be really appreciated.
...ANSWER
Answered 2020-Jul-24 at 19:01This error is telling you that it is not finding in the app.component.spec.ts
file the provider DEFAULT_LOCALE.
What you need to do is. You need to register DEFAULT_LOCALE
in your app.component.spec.ts
file under TestBed.configureTestingModule
as a provider:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular-localization
npm
gulp npm install -g gulp
bower npm install -g bower
The easiest way to install the ngLocalize module is via Bower:.
Download the latest release.
Clone the repo: git clone https://github.com/doshprompt/angular-localization.git.
All overridable configuration options are part of localeConf within the ngLocalize.Config module that comes bundled along with this plugin and works alongside ngLocalize. the folder off the root of your web app where the resource files are located (it can also be used as a relative path starting from the folder where your index.html file is located). the locale that your app is initialized with for a new user. commonly occuring words, phrases, strings etc. are stored in this file (it is used to check whether the service itself is ready or not as it is loaded during bootstrap). the extension for all resource files spanning across all languages. whether to save the selected language to cookies for retrieval on later uses of the app. works in conjuntion with persistSelection and provides the cookie name for storage. a regular expression which is used to match which custom data attibutes may be watched by the i18n directive for 2-way bindings to replace in a tokenized string. the delimiter to be used when passing params along with the string token to the service, filter etc. a regular expression which is used to match the names of the keys, so that they do not contain invalid characters. If you want to support an extended character set for the key names you need to change this. NOTE: There is one caveat; if you want to override at least one particular option, then you must explicitly set any other options explicitly to their default values (shown above). Publicly exposed events may be found as part of localeEvents situated within the ngLocalize.Events module that comes pre-loaded along with this plugin and is leveraged internally by the service. NOTE: All of these are sent by $rootScope so that they may be accessible to all other $scopes within your app. Otherwise you could alternatively always choose to inject $rootScope and consume (ingest) the aforementioned events. This plugin relies on the developer(s) to let it know of all languages currently part of the codebase. These languages must be defined as per the [Language Culture Name specification] (http://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx). It is broken up into two parts, both of which are located in the ngLocalize.InstalledLanguages modules separated out as localeSupported and localeFallbacks. The first is responsible for the list of languages currently supported as the name suggests while the latter takes care of fallbacks when a particular language is present but not for the region from which the app is being opened (e.g. en-GB). As a last resort, if none of these are valid and/or available, it will fallback to the defaultLocale configured as part of the options during initialization. NOTE: Since the plugin does not rely on auto-discovery mechanisms of any kind, and none of the sort is planned for the future, it is possible to start creating language resource files before they must be fully integrated. Simply leaving them out of the declaration will suffice meaning it will cause them to be ignored when deciding on which language to show up on the page(s).
localeEvents.resourceUpdates: when a new language file is pulled into memory
localeEvents.localeChanges: when the user chooses a different locale
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page