Can you provide your solution to me please?
Can you provide your solution to me please?
Strange, it's not working for me now either. I'm going to investigate. Will share anything I find.
Ah, got it working, I had an issue in my translation piece. Let me share code below.
So...
indexpage, scope function:
code$scope.setLanguage = function (languageCode) {
$translate.use(languageCode);
}
/code
main page button:
As per tutorial, the "title" element is set to:
code{{ 'TITLE' | translate }}/code
AngularTranslate javascript:
code
define( [ 'require', 'angular' ], function( require, angular ){
/**
* Read more about AngularJS modules in official docs:
* https://docs.angularjs.org/guide/module
*
* Check here how to paste 3rd party modules:
* https://devcenter.appery.io/documentation/angularjs/resources/#Using_3rd_party_modules
*/
var module = angular.module('AngularTranslate', ['pascalprecht.translate']);
//module.provider(name, providerType);
//module.factory(name, providerFunction);
//module.service(name, constructor);
//module.value(name, object);
//module.constant(name, object);
//module.decorator(The, This);
//module.animation(name, animationFactory); //animations take effect only if the ngAnimate module is loaded
//module.filter(name, filterFactory);
//module.controller(name, constructor);
//module.directive(name, directiveFactory);
//module.run(initializationFn);
module.config(
function($translateProvider) {
$translateProvider.translations('en', {
TITLE: 'Hello',
FOO: 'This is a paragraph.',
BUTTON_LANG_EN: 'english',
BUTTON_LANG_DE: 'german'
});
$translateProvider.translations('de', {
TITLE: 'Guten Tag',
FOO: 'This is a paragraph.',
BUTTON_LANG_EN: 'english',
BUTTON_LANG_DE: 'german'
});
$translateProvider.translations('fr', {
TITLE: 'Bonjour',
FOO: 'This is a paragraph.',
BUTTON_LANG_EN: 'english',
BUTTON_LANG_DE: 'german'
});
//$translateProvider.determinePreferredLanguage();
$translateProvider.fallbackLanguage('en');
$translateProvider.preferredLanguage('en');
});
});
/code
And for testing, I have buttons with ng-click set to:
setLanguage('en');
setLanguage('fr');
setLanguage('de');
That seems to be it!
I create a scope function with argument in index page and put the code as you mentioned in AngularTranslate
however when I press the translate button, error shows up as: $translate is not defined
Dammit, I missed a line.Sorry!
code
$scope.setLanguage = function (languageCode) {
var $translate = Apperyio.get('$translate');
$translate.use(languageCode);
}
/code
Thank you for your patience and explanations to guide through, it works like a charm!
Hi Mark,
Glad to have helped.
Andy