Tips for consolidating all language locales into a single JSON file using Angular Translate

Is there a way to link all English variants ('en-AS', 'en-BE') to one file called 'en' (en.json)?

.registerAvailableLanguageKeys(
            [
                'en_US',
                'de_DE'
            ], {
            'en_US' : 'en', 'en-AS': 'en', 'en-AU': 'en', 'en-BB': 'en', 'en-BE': 'en', 'en-BM': 'en', 'en-BW': 'en', 'en-BZ': 'en', 'en-CA': 'en', 'en-GB': 'en', 'en-GU': 'en', 'en-GY': 'en', 'en-HK': 'en', 'en-IE': 'en', 'en-IN': 'en', 'en-JM': 'en', 'en-MH': 'en', 'en-MP': 'en', 'en-MT': 'en', 'en-MU': 'en', 'en-NA': 'en', 'en-NZ': 'en', 'en-PH': 'en', 'en-PK': 'en', 'en-SG': 'en', 'en-TT': 'en', 'en-UM': 'en', 'en-US': 'en', 'en-US-POSIX': 'en', 'en-VI': 'en', 'en-ZA': 'en', 'en-ZW': 'en',
            'de_DE' : 'de', 'de_AT': 'de', 'de_BE': 'de', 'de_CH': 'de', 'de_DE': 'de', 'de_LI': 'de', 'de_LU': 'de'
        })

For further reference, here is a plunker link http://embed.plnkr.co/TP9WmO/

Answer №1

Here is a simple solution to mapping all variations of the same language to one file

.registerAvailableLanguageKeys(['es', 'en','pt','fr','de','ja','it'], {
    'en-*':'en', 
    'es-*':'es', 
    'pt-*':'pt',
     'fr-*':'fr',
     'de-*':'de',
     'ja-*':'ja',
      'it-*':'it'
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unable to connect CSS/JS files to the HTML page

I followed a tutorial to set up my project which can be found here: However, when I run the gulp file, the CSS/JS files are not being linked. I have applied a background color to the body but it is not showing up. I installed Bootstrap 4 using npm and ad ...

A guide on transferring a Vue component to a custom local library

After successfully creating components using template syntax (*vue files), I decided to move common components to a library. The component from the library (common/src/component/VButton): <template> <button ... </button> </templat ...

What is the best way to convert JSON to a Java object while utilizing the RequestBody interface in a RESTful API call?

Here is the project structure for a Maven project I am working on: Project 1 -> Core-part (containing interfaces): interface Foo{ public String getStr1(); public setStr1(String str1); public List<? extends Bar> getBarList(); pub ...

Make a request for data using the .getJSON function to the

I'm slightly confused about the current situation. For example... It seems that this link is retrieving JSON data based on certain numbers specified in the URL, but I am unsure how these variables are being processed. Is there a server-side script ge ...

Developing JavaScript entities for manipulation controls

Currently, I am developing a customized WebControl that incorporates AJAX features. This control is built upon the System.Web.UI.WebControls framework and includes the registration of control-specific JavaScript using ClientScript.RegisterClientScriptReso ...

Angular JS and TypeScript - Issue: ng:areq Invalid Argument "Argument 'XXXXXX' is not a function, received undefined"

Encountering a specific error mentioned in the title. I organized models and controllers into distinct files saved under models and controllers folders respectively. Upon trying to establish a connection between them, I received an error stating "ng:areq ...

In JavaScript, unchecking a radio button results in all options becoming uncheckable

I have a pure CSS accordion and I want to enhance it with some JavaScript functionality for users who have JavaScript enabled. The CSS accordion currently utilizes the :checked pseudo-class. The new feature I am looking to add is: if a button that is alre ...

Python - separate items into a list

I am facing a challenge with a JSON response that contains two sections that require numerical comparisons. Although I can access the values, I am finding it difficult to eliminate the square brackets [] and split the entries using commas. The structure of ...

Having trouble with sending information to the PHP server, unable to determine the root cause

Can someone help me figure out why the data from a form being sent to a php script for sending an email isn't working correctly? It's part of a template code but I suspect there might be an error. Specifically, I believe the {'userName' ...

Whenever I try to execute the command `electron .` in the electron-quickstart project, I immediately encounter an error within the

Upon successfully installing Electron, I attempted to run it using "electron" or "electron -v" commands. Unfortunately, I encountered an error while running it on Windows 10. C:\Windows\System32\electron-quick-start>electron -v modu ...

Experiencing difficulties establishing a connection between the React client and Node.js server using SocketIO

I am currently getting familiar with socketIO and have successfully set up a basic nodejs server. However, I am facing an issue where my nextJS app is unable to connect to the server as expected. Despite no errors being displayed, the messages that should ...

File access has been denied

I am currently developing an Android app and I need to save JSON data to a .txt file. The .txt file is located in the root of my project. This is how I currently parse the JSON: string url2 = "http://new.murakami.ua/?mkapi=getProducts"; JsonValue json = ...

The call stack limit has been exceeded in VueJS/VueX

I'm currently developing a Vue project with Vuex for state management. However, I encountered a Maximum call stack size exceeded error in my console when attempting to bind actions and getters in my component using mapActions and mapGetters. I'm ...

When you press multiple buttons, the correct button will reveal an image while the incorrect buttons will display an X

Could you lend a hand with the code below? Your assistance is truly appreciated :). Thank you in advance. I need help setting up a functionality where clicking on the correct button (e.g. H) will display a checkmark and a forward link image. If the user c ...

Angular's $cookies are limited to functioning solely on the 'localhost' domain

Prepare yourself, an unusual Angular / IIS issue is on the horizon: I have developed an Angular 1.4.0 application that utilizes $cookies to store the oauth access token once a user logs in. Everything runs smoothly on localhost but encounters issues when ...

What is the best way to incorporate a string value from an external file into a variable in TypeScript without compromising the integrity of special characters?

I am encountering an issue with importing a variable from a separate file .ts that contains special characters, such as accents used in languages like French and Spanish. The problem I am facing is that when I require the file, the special characters are ...

Mongoose and ES6 promises are not delivering the expected results

I'm currently working on a piece of code that involves creating an array of promises to save specific numbers. The issue I'm facing is that when the output is printed, it displays the same record 10 times. Below is the code snippet: 'use s ...

Utilizing AJAX in Wordpress to Dynamically Update HREF Links

My website now has AJAX functionality, and you can see a live example at www.mathewhood.com. I am interested in changing the URL format when clicked from To something like , without the /sitefiles/ for security reasons. Below is my code. If anyone is ex ...

How do I utilize the file handler to execute the flush method within the Deno log module using Typescript?

I'm having trouble accessing the fileHandler object from my logger in order to flush the buffer to the file. This is the program I am working with: import * as log from "https://deno.land/<a href="/cdn-cgi/l/email-protection" class="__cf_emai ...

Tips for ensuring the CSRF token functions properly on the browser when utilizing Django and React

Apologies in advance if this question seems beginner-friendly, but I have developed an application with Django backend and React frontend. I am currently working on implementing the CSRF token for the post request on the create endpoint using the code snip ...