Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bernard Moes 13 posts 134 karma points
    Jul 28, 2017 @ 10:48
    Bernard Moes
    0

    Default package language

    I am trying to add localization support to my package and want to keep all my language files in a single place. One thing that bothers me is that there appears to be no such thing as a default.xml to catch all unsupported languages. Right now I have to provide the defaults inside my html code. Example:

    <localize key="general_label">Default value</localize>
    

    Is there any workaround to solve this issue?

    EDIT: the default value doesn't work this way either. It just returns general_label when I set my language to an unsupported language. How do I supply a default value?

  • Bernard Moes 13 posts 134 karma points
    Jul 28, 2017 @ 13:49
    Bernard Moes
    0

    At least I fixed the inline default. The directive below only replaces the inline default "Default value" when a translation is available:

    function CustomLocalize(localizationService) {
        return {
            restrict: 'E',
            scope: {
                key: '@'
            },
            replace: true,
    
           link: function (scope, element, attrs) {
                var key = scope.key;
                localizationService.localize(key).then(function (value) {
                    var re = new RegExp("\^\\\[\\w\+\\\]\$");
                    if (!re.test(value)) {
                        element.html(value);
                    }
               });
            }
        }
    }
    

    Still I didn't find a way to centralize defaults. If anyone could help me here I'd appreciate it.

Please Sign in or register to post replies

Write your reply to:

Draft