is it possible to have a table for the "localeLocationPattern" variable?
toofff opened this issue · 7 comments
The goal would be to have several sources of dynamically import i18n file.
for exemple :
'use strict';
angular.module('MyApp').config([
'$translateProvider', 'tmhDynamicLocaleProvider', function($translateProvider, tmhDynamicLocaleProvider) {
$translateProvider.useStaticFilesLoader({
prefix: 'i18n/json/locale-',
suffix: '.json'
});
$translateProvider.preferredLanguage('fr');
$translateProvider.useLocalStorage();
$translateProvider.useSanitizeValueStrategy('escape');
tmhDynamicLocaleProvider.defaultLocale('fr');
return tmhDynamicLocaleProvider.localeLocationPattern([
'i18n/angular-i18n/angular-locale_{{locale}}.js'
'i18n/moment/{{locale}}.js'
]);
}
])
@toofff this looks interesting, but I am not sure what the specific behavior should be. Is the idea that each location is checked in sequence and accept the first locale that is successfully loaded?
The goal is to load all local that I have in my possession. For the moment the plugin can load a file type, for my project I want to load local files from several plugins at the same time.
Is what I am quite clear in my explanations?
Hello,
I use this as dependency :
To import the translation files dynamically on my project, I use your dependency.
With several dependency, I have several translation files to be imported dynamically.
Currently I can dynamically import one file type but I would like to have the opportunity to import more files dynamically. See my first example.
another benefit to implementing this kind of feature would be that we aren't relegated to using relative urls -- every time my app tries to dynamically load a locale file while not at the root or a 1st-level route, it appends at the path level and can't find the files --
ie,
loading at
myangularsite.com/login
works great and pulls from
myangularsite.com/angular/i18n/angular-locale_en-us.js
but loading at
myangularsite.com/paths/potato
instead tries to pull from
myangularsite.com/paths/angular/i18n/angular-locale_en-us.js
and can't be loaded, so I'm basically forking to make this library work for us. My own particular problem could also be resolved by use of a absolute/relative boolean as an option.
@aaronhuckabee if you need an absolute URL, you should be able to do
// Check that there is a "/' at the begging of the path
tmhDynamicLocaleProvider.localeLocationPattern('/angular/i18n/angular-locale_{{locale}}.js');
This is now possible by using tmhDynamicLocaleProvider.addLocalePatternValue