Here is fiddle
Is it possible in angular translate to check if the key-value of another language is not available, then it can pull out this key value from another language? As in the example, I have English and Spanish. And one key value ("CONFIRM_LABEL" in the example) is not available in Spanish. Can I pull this data from the English version?
HTML
<div name="info" ng-controller="myctrl">
<label translate="TERMS_LABEL"></label>
<h4 translate="ZIPCODE_LABEL"></h4>
<p translate="LAST_NAME"></p>
<p translate="CONFIRM_LABEL"></p>
<button type="submit" ng-click="changeLanguage('de')" >Spanish</button>
<button type="submit" ng-click="changeLanguage('en')" >English</button>
Js
var demo = angular.module('demo', ['pascalprecht.translate']);
demo.controller('myctrl',function ($scope,$translate)
{
$scope.changeLanguage = function (key)
{
$translate.use(key);
};
})
demo.config(function ($translateProvider) {
$translateProvider.translations('en', {
"TERMS_CONDITIONS":"TERMS & CONDITIONS",
"TERMS_LABEL":"TERMS",
"ZIPCODE_LABEL":"ZIP CODE",
"LAST_NAME":"Last Name",
"CONFIRM_LABEL": "Confirm Number ",
})
.translations('de', {
"TERMS_LABEL": "Términos",
"FORM_LABEL": "Información ",
"LAST_NAME": "Apellido",
"ZIPCODE_LABEL": "Código Postal"
});
$translateProvider.preferredLanguage('en');
})
source
share