We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6726
    • 7,075 Posts
    This is translated from the original thread posted in the french boards by the snippet author, coroico. Since I deem this snippet to be the best current localization option, I thought translating and posting it here could greatly help its testing and possible improvement. Right now only a handful of people are even aware it exist, and it’s too bad ! Here is the translation :

    Quote from: coroico at Oct 25, 2007, 06:01 PM

    I wanted to build a multi-lingual website, thus I wrote a snippet called "l10n" (stands for localization) which might be of interrest to some...

    Features

    • lang switcher, with a select
    • build the select from the list of available languages
    • stores and remembers the selected language with a cookie
    • returns the current language
    • return the current’s language language file, associated with it
    • loads the home container for the given language
    • handles date and time localization
    • translate labels (like gettext)

    (Note from translator : skipped the parameters, since they’re documented in english in the snippet code)


    What’s missing :

    the ability to choose between different select mode : flag instead of language code, for example.
    labels can be used only to translate labels of short terms.

    Sample use : here.

    Use FireFox, still having problems with IE. Change language to see how it reflects on the Wayfinder powered menu, the AjaxSearch form, the MaxiGalery Galeries... etc.

    Install

    The zip fil contains the directory structure for the l10n snippet (copy into assets/snippets)

    The assets/snippets/l10n/doc directory contains sample templates and help files.
      .: COO - Commerce Guys - Community Driven Innovation :.


      MODx est l'outil id
      • 17895
      • 209 Posts
      Hi there... I found the French post and I was trying to translate when I found you! :-P

      Ok then, here is Yet Another Language Switcher beast... one question about that: how can the snippet know which page in language X correnspond to the one in language Y ??
        Daniele "MadMage" Calisi
        • 6726
        • 7,075 Posts
        I might be wrong but the snippet calls are used directly in the document properties field :



        also pages use an argument (in the example, something like http://www.wangba.fr/avis.html&ln=en)
        the argument is then used to check which language file is to be used (check the lang folder).

        This of course implies you have defined language strings...

        I haven’t had the time to actually test this a lot, but I think that’s how it goes about it...
          .: COO - Commerce Guys - Community Driven Innovation :.


          MODx est l'outil id
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Thank you! And merci boucoup to you too, coroico!
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 17895
            • 209 Posts
            Some time ago I wrote a plugin that does something very similar to this. It’s very simple, indeed. You have to write in your page things like:

            {$it|questa è una pagina|$en|this is a page}

            and the plugin select the right string, based on the language currently chosen. It can lead to some big problem if you have 100 different languages (but usually you do not have), but this plugin is useful for example for snippets that are not localized (Jot is not localized, unfortunately, for example).
              Daniele "MadMage" Calisi
              • 29076
              • 615 Posts
              Some time ago I wrote a plugin that does something very similar to this.
              Hey, do you remember where you putted that plugin? It sounds like it could be worth a try. laugh
                I think, thererfor I am! But what I am, and why...?
                • 7455
                • 2,204 Posts
                and does it use tv’s for the content in other languages?
                  follow me on twitter: @dimmy01
                  • 17895
                  • 209 Posts
                  Quote from: Sylvaticus at Jan 30, 2008, 04:35 AM

                  Some time ago I wrote a plugin that does something very similar to this.
                  Hey, do you remember where you putted that plugin? It sounds like it could be worth a try. laugh

                  I’ll look for it in my hard disk and let you know in this thread when I find smiley
                    Daniele "MadMage" Calisi
                    • 4971
                    • 964 Posts
                    @madmage

                    {$es|¿alguna noticia respecto a este plugin?|$en|any news regarding this plugin?}
                      Website: www.mercologia.com
                      MODX Revo Tutorials:  www.modxperience.com

                      MODX Professional Partner
                      • 4971
                      • 964 Posts
                      Has anybody tried this snippet with a large site?

                      I mean, it looks wonderful to translate labels and small text (as indicated)
                      but does it work with more complex sites: three column designs, larger text,
                      sidebars, tables, etc.

                      The document template provided changes everything but it still contains
                      [*content*] and I assume then that we need to have a modx document for each
                      page in each language, thus defeating the purpose of this shippet...???
                        Website: www.mercologia.com
                        MODX Revo Tutorials:  www.modxperience.com

                        MODX Professional Partner