Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9153629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:18:15+00:00 2026-06-17T12:18:15+00:00

There is a use case that is quite popular when building international web application:

  • 0

There is a use case that is quite popular when building international web application:

There are localized templates for each culture, with name convention like ‘en_US/name.html’, ‘ru_RU/name.html’ etc.

User’s locale setting could be get only after user logged (or user can select locale).

So the best option that I found is to provide localization value using DI (so it could be updated form anywhere – or when I recieve response from backend with user config, or when user select something).

But routing could be configured only in configuration step, where ‘values’ could not be injected. So you can’t inject locale config and add templateUrl according to that value.

Here is a Plnkr example do illustrate my solution.

Only other solution I see, is to modify private array of routes (using $route.routes[]), but it sounds like ugly hack.

Is there are other solutions to implement this common use case of using localized templates?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:18:16+00:00Added an answer on June 17, 2026 at 12:18 pm

    There might be ways to do this as you want, like overriding templateCache instead of modifying routing but I’m going to approach this issue differently.

    In your approach, as your site grows it would be very difficult to maintain (at least) 2 copies of templates. If you support more languages, then you’d be in trouble much shorter.

    I’d create a service which holds dictionary like objects for languages.

    angular.module("myApp", [])
           .factory("Internationalization", function () {
               var dict: {
                   en_US: {
                       hello: "Hello,"
                   },
                   fr_FR: {
                       salut: "Salut,"
                   }
               };
               var get = function (locale, key) {
                   return formatdict[locale][key];
               }
               return {get: get};
           });
    

    Then you can inject the service in the controller and attach it to scope.

    This should help you getting started, you might want to check this out if you want string.format support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following use case: There's a class called Template and with that
Are there rules of thumb that help determine which to use in what case?
we have a typical web application stack. there are 120 selenium (webdriver) tests that
I have following use-case: there are several assemblies decorated with ProtoContract classes and I
My use case expects heavy read load - there are two possible model design
I have a use case with NServiceBus explained in this question. Essentially there is
Is there a pure-java way of setting the android:button attribute? My use case is
Is there a way to use one CASE statement and return 2 different values?
Is there any use for FormsAuthentication.Authenticate() is real-world web applications? Why should we write
When debugging a function I usually use library(debug) mtrace(FunctionName) FunctionName(...) And that works quite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.