facultymatt / angular-unsavedChanges

angular-unsavedChanges
175 stars 81 forks source link

Anyone using angular-gettext? #61

Open burakkilic opened 8 years ago

burakkilic commented 8 years ago

Hello;

I am using angular-gettext for translation.

I need to inject gettext service to configuration but it didn't work.

MetronicApp.config(function(unsavedWarningsConfigProvider){
unsavedWarningsConfigProvider.navigateMessage = gettext("Navigate message");
unsavedWarningsConfigProvider.reloadMessage = gettext("You will lose unsaved changes if you reload this page!");
});

What should I do to translate alert messages?

v0d1ch commented 8 years ago

Can't you use injector to inject gettext and use it? var getT = $injector.get('getText');

burakkilic commented 8 years ago

Thank you, I'll try

arski commented 8 years ago

doing the above works, but it only marks the string for translation. You cannot to gettextCatalog.getString inside the config because you can't inject another service (gettextCatalog) into the config.

What we need to do is replace

if ($injector.has('$translate') && useTranslateService) {
    return $injector.get('$translate').instant(message);
} else {
    return false;
}

with

if ($injector.has('$translate') && useTranslateService) {
    return $injector.get('$translate').instant(message);
} else if ($injector.has('gettextCatalog') && useTranslateService) {
    return $injector.get('gettextCatalog').getString(message);
} else {
    return false;
}

could you guys do this please?