Copied to clipboard

Flag this post as spam?

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


  • Adriano Fabri 469 posts 1633 karma points
    Apr 19, 2016 @ 09:43
    Adriano Fabri
    0

    Problems with localization in ng view

    Hi to all, I have a problem with the localized key. In my ng view I use:

    <localize key="Button">Button</localize>
    

    but when I see the page, It display the text "[general_Button]"

    I have 2 languages (En-US and It-IT) and my dictionary item is inside a subcategory:

    Area
        |=> Section
            |=> Button
    

    I tried also with:

    <localize key="Area_Section_Button">Button</localize>
    

    as described into another forum, but the text displayed is [AreaSectionButton]

    What's wrong?

    Adriano

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Apr 19, 2016 @ 10:01
    Bjarne Fyrstenborg
    0

    Hi Adriano

    If you have added add key in language files under buttons, e.g.

    <area alias="buttons">
        <key alias="myButton">Button</key>
        ...
    </area>
    

    then in your view you should refer to it this way:

    <localize key="buttons_myButton">Button</localize>
    

    Also be aware of the casing.

    But for your own stuff and packages, it might be better to add your own unique area to ensure it doesn't conflict with any other core language keys.

    The reason why it returns [general_Button] is that it didn't find a key "Button" in area "general" - when you don't specify an area it will by default lookup in the area "general".

    /Bjarne

  • Adriano Fabri 469 posts 1633 karma points
    Apr 19, 2016 @ 11:57
    Adriano Fabri
    0

    No I didn't added my button key in the language file. I create my custom keys in the dictionary (settings section).

    Where I must add my custom area? Directly in the en.xml and it.xml files?

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Apr 19, 2016 @ 12:20
    Bjarne Fyrstenborg
    101

    The localize directive and localizationService is looking for keys in either /App_Plugins/MyPackage/Lang/ .. or in core /Umbraco/Config/Lang/ folders..

    I am not sure whether there is any Angular services to lookup dictionary items in settings section or you need to create your own.

    But if you are developing a property editor or some stuff in a dashboard or a custom section, you should have a folder inside App_Plugins folder, e.g /App_Plugins/MyPackage/ .. inside that folder you can create a folder Lang with xml files for each language, da-DK.xml, en-GB.xml, en-US.xml etc.

    For en-US.xml it could be similar to this:

    <language alias="en" intName="English (US)" localName="English (US)" lcid="" culture="en-US">
      <area alias="myPackage">
          <key alias="button">Button</key>
          ...
      </area>
    </language>
    

    /Bjarne

  • Adriano Fabri 469 posts 1633 karma points
    Apr 19, 2016 @ 12:25
    Adriano Fabri
    0

    It work like a charm!!! :-)

    Thank you for your support.

    Bye

  • Adriano Fabri 469 posts 1633 karma points
    Apr 19, 2016 @ 13:03
    Adriano Fabri
    0

    Sorry, another one thing.

    When I create my custom area and key into /Umbraco/Config/Lang/en.xml file, it function properly.

    Now I want to create my custom Lang folder and I put inside my custom en.xml file

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <language alias="en" intName="English (UK)" localName="English (UK)" lcid="" culture="en-GB">
        <creator>
            <name>ADRIANO</name>
            <link></link>
        </creator>
        <area alias="sections">
            <key alias="ADRIANO">ADRIANO</key>
        </area>
        <area alias="ADRIANO">
            <key alias="Button">Button</key>
        </area>
    </language>
    

    I put my custom Lang folder into my Package folder.

    App_Plugin
        |=>ADRIANO
            |=>backoffice
                |=>test
    

    I tried to put the "Lang" folder in

    App_Plugin/ADRIANO

    and also in

    App_Plugin/ADRIANO/backoffice/test/

    but It don't function. Always the text of my button is

    [ADRIANO_Button]

    What's wrong?

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Apr 19, 2016 @ 14:52
    Bjarne Fyrstenborg
    0

    If you use Umbraco 7.3.x+ you don't need to edit language keys in core language files in /umbraco/config/lang/..
    Just add a language folder "lang" to your folder in AppPlugins.. And I think it must be located at root level in your plugin folder, so in "/AppPlugins/ADRIANO/"

    Furthermore you should ensure that language files in this folder (in /App_Plugins/ADRIANO/lang/) is named like da-DK.xml, en-GB.xml and en-US.xml

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Apr 20, 2016 @ 02:59
    Nicholas Westby
    0

    In case anybody is curious, here is the documentation for what Bjarne is describing: https://our.umbraco.org/Documentation/Extending/Language-Files/Language-Files-For-Packages/

  • Adriano Fabri 469 posts 1633 karma points
    Apr 20, 2016 @ 08:59
    Adriano Fabri
    0

    I'm using Umbraco version 7.4.1 assembly: 1.0.5891.23238

    I have read that link and I put the Lang folder (with my custom en-us.xml file) in

    App_Plugin/ADRIANO

    but the text of my button is always

    [ADRIANO_Button]

    I don't understand if I must declare it or include a directive to tell Umbraco that there is a custom language files or Umbraco should find automatically my custom language file and use it

    The content of my en-us.xml file is:

    <?xml version="1.0" encoding="utf-8" standalone="yes"?>
    <language alias="en_us" intName="English (US)" localName="English (US)" lcid="" culture="en-US">
        <creator>
            <name>ADRIANO.</name>
            <link>http://mydomain.com</link>;
        </creator>
        <area alias="ADRIANO">
            <key alias="Button">Delete selected user(s)</key>
        </area>
    </language>
    

    In my edit.html file I wrote

    <button type="button" id="btnDeleteUsers" name="btnDeleteUsers" ng-click="save(settings)" data-hotkey="ctrl+s" class="btn btn-primary">
        <localize key="ADRIANO_Button">Default Text</localize>
    </button>
    

    But the text of my button is always

    [ADRIANO_Button]

    :-(

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Apr 20, 2016 @ 09:34
    Bjarne Fyrstenborg
    1

    Can you try these steps:

    Ensure language files is located in /App_Plugins/ADRIANO/Lang/ and is named en-US.xml (not sure if casing of this file name matter).

    Ensure you backoffice user is using English (United States) - default is English (United Kingdom).

    When changing language for user it also seems it isn't enough just to refresh browser window - you have to logout and login again.

    /Bjarne

  • Adriano Fabri 469 posts 1633 karma points
    Apr 20, 2016 @ 10:02
    Adriano Fabri
    0

    OK...thanks Bjarne, I found the problem.

    The name of my custom file must be the culture name

    en-US.xml or it-IT.xml or en-GB.xml).

    I called the files like the umbraco language file

    en_us.xml or it.xml or en.xml

    Now...it works perfectly :-)

    Thank you to all for support.

    Bye

  • Bjarne Fyrstenborg 1284 posts 4038 karma points MVP 8x c-trib
    Apr 20, 2016 @ 10:13
    Bjarne Fyrstenborg
    0

    Great!

    I am glad you solved the issue.

    /Bjarne

Please Sign in or register to post replies

Write your reply to:

Draft