We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36604
    • 268 Posts
    Hi,

    I'm still a little bit puzzled by the lexicon concept: ok, each component and the core comes with their own lexicon. just fine.
    But for i18n purpose I'd like to be able to add any kind of personal lexicon, not specifically attached to any component, just to be able to pick up some %key everywhere I need a title or hard coded text or whatever in my chunks/tpl ...

    Should I use the core lexicon for this ?

    Thank you

    Thank you
      • 36604
      • 268 Posts
      hmm. a little up ?
        • 3749
        • 24,544 Posts
        You could use the core lexicon. It's always loaded and if you make your additions in the Manager (System -> Lexicon Management), they will survive upgrades to MODX.

        You also have the option to create your own lexicon file(s) in modx/core/lexicon/en/ (or whatever). Then you can call the file mylexicon.inc.php and, IIRC, in your Revolution tags:

        [[%key? &language=`en` &namespace=`core` &topic=`mylexicon`]]



        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html


        [ed. note: BobRay last edited this post 11 years, 8 months ago.]
          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
          • 36604
          • 268 Posts
          Hi,
          thank you.

          So I can build my own lexicon file (I tried) but it was not accessible throught the lexion manager menu.

          I do not understand :
          Then you can call the file mylexicon.inc.php and, IIRC, in your Revolution tags:

          I guess adding a file is not enought. can you explain 'call the mymexicon.inc.php' ? Are you talking about writing a snippet ??

          Thank you
            • 3749
            • 24,544 Posts
            If you want it available throughout the Manager, it would probably be best to add the strings to the core Lexicon in System->Lexicon Management.

            Otherwise you'd have to write code to load the lexicon file and put the code in a plugin or snippet.



            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 36604
              • 268 Posts
              Well, thank you.

              so here's a default functionality that would be welcome in next release...
              Multilingualism is a basic stuff for any platform and having to reinvent it each time is puddy a pain.
                • 3749
                • 24,544 Posts
                I'm not completely clear on what you want. I thought you wanted your language strings to show in the MODX Manager (and I got the tag format wrong above -- I was thinking of how you load lexicons in code).

                If you just want to show your custom language strings in the front end, creating your own file (in the right place) and using the correct language tags will do it.

                If you create a lexicon file called mystrings.inc.php and put it in the core/lexicon/en/ directory with stuff like this in it:

                $_lang['my_custom_string'] = 'What I want to appear';


                This tag should show the string from that file:

                <p>
                    My Custom String: [[%my_custom_string?
                        &language=`en`
                        &namespace=`core`
                        &topic=`mystrings`
                   ]]
                </p>


                You could also put the file somewhere else and define a namespace (other than core) in System -> Namespaces.

                For example, if the file were: core/components/mydirectory/lexicon/en/mystrings.inc.php, the namespace path would be: {core_path}components/mydirectory/ and the tag would be:

                <p>
                    My Custom String: [[%my_custom_string?
                        &language=`en`
                        &namespace=`mydirectory`
                        &topic=`mystrings`
                   ]]
                </p>
                



                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 36604
                  • 268 Posts
                  Ho... Ok I see.

                  In fact , I tried to add my own file as you described in your ex #1

                  What puzzled me is this way does not make the file to be visible and editable directly through the lexicon manager ( in the modx manager) like other files coming with add dons or core.
                  So I even did not tried to use it and stop my tests...

                  I did not understood yet I could create my namespace as you explain in you ex#2 that fit ( I will test today) what I was looking for.

                  Thanks again!
                    • 3749
                    • 24,544 Posts
                    If you put them under the core directory, the "Reload All Core Entries" button at the bottom might load them into the grid, as long as none of them conflict with existing core entries (and you should make sure they don't if they're going in the core directory).


                    ------------------------------------------------------------------------------------------
                    PLEASE, PLEASE specify the version of MODX you are using.
                    MODX info for everyone: http://bobsguides.com/modx.html
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting