We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33992 ☆ A M B ☆
    • 455 Posts
    EasyLingual, plugin to create multilingual sites v0.99

    Description:
    EasyLingual gets a ISO(2char) language code via "&lang" GET query and save it as a MODx cookie ({&dollarfix;} _SESSION).
    This plugin replaces
    [%lang%] with 2char language like en, fr, fa, ... (will be EMPTY if current language is default language)
    [%language%] with lowercased language like english, french, persian, ... (will be EMPTY if current language is default language)
    [%LANG%] with 2char language like en, fr, fa, ... (always)
    [%LANGUAGE%] with lowercased language like english, french, persian, ... (always)
    [%dir%] with "rtl" when language is RTL else "ltr"
    [%align%] with "right" when language is RTL else "left"
    in Templates, document Content and document Introtext before parsing MODx tags, so you can use it in chunk names, snippets names and parameters and specially template variables.

    EasyLingual gets language via "lang" GET query so you should add links like below for choosing language:
    <a href="[~[*id*]~]&lang=en" title="English">English</a>
    <a href="[~[*id*]~]&lang=fa" title="Persian">Persian</a>


    Examples of usage:
    To create a multilingual site, you need to create MODx document fields which you need as TVs, for example in my site only "page title" and "content" need to change for each language, so i create a textarea TV (with editor) and name it "decontent" and another for page title "depagetitle". So i need to put TV below in my template instead [*content*]:
    [*[%lang%]content*]

    when user chooses the "German", this TV will change to [*decontent*] and in standard mode, [%lang%] is empty and TV will be [*content*].

    EasyLingual ONLY converts tags in Templates, Page content and page Introtext. it means if i use way above, i can use [%%] tags in value of [*content*] but i can’t use it in value of [*decontent*] TV! but maybe in need to use plugin tags as page content.
    In this way i should create another TV like [*encontent*], put [*content*] in my template, and put tags below in PAGE CONTENT:
    [*[%LANG%]content*]

    So when language is English, [*content*] contains [*encontent*] and when language is German [*content*] contains [*decontent*] and put other snippets and chunks and tags current document.

    This plugin DOES NOT converts [% %] in chunks but if you need use different chunks as tpls, You must create a chunk for each language like this {{[%LANGUAGE%]Chunk}}, so if language is Persian it will be {{persianChunk}} in snippets like Ditto:
    [[Ditto? &language=`[%LANGUAGE%]` &tpl=`[%LANG%]_ditto`......]]


    so when language is Espanish, snippets will be
    [[Ditto? &language=`espanish` &tpl=`es_ditto`......]]


    You can use it in chunk tags: {{[%language%]Chunk}}, so if language is French, it will be {{frenchChunk}}

    EasyLingual tags also converts in placeholder tags for your custom snippets.


    EasyLingual also has feature for RTL languages. For this languages, using translations is not enaugh and usually the views must change to LTR and RTL too. So you can use [%dir%] and [%align%] tags in your templates (e.g. <div dir="[%dir%]" align="[%align%]">)
    It let you create dynamic templates for RTL and LTR languages wink


    Installation:
    1. Create a plugin, copy/paste this contents to plugin codes, name it "EasyLingual" and put "plugin to create multilingual sites v0.99" in description.
    2. In Configuration tab, copy.paste code below in "plugin configuration" fields
    &default_lang=default language;string;
    press button and type 2-char language as default language else plugin will use MODx manager_lang_attribute.
    3. In Events tab, check events below:
    OnLoadWebDocument
    4. Save it. Create necessary TVs, Chunks and Snippets. Put plugin valid tags in Templates, Document content and Document introtext.


    REMEMBER
    EasyLingual ONLY converts [% %] tags in Templates, Page content and page Introtext. NOT in TVs and CHUNKs!
    MODx caches only one language data of page. so multilingual pages MUST be uncachable!
    EasyLingual runs on Load Web Document, it must be in top of execution order of other plugins.!


    Good luck
      God loves me. 【ツ】


      MODX.ir (Persian Support)

      Boplo.ir/modx/ (Persian)
      • 16545
      • 358 Posts
      Thx for sharing, it’s a very important stuff that I’d looked for ...
      How about bugs? Could I use this one in production or it must be good tested before?
        • 33992 ☆ A M B ☆
        • 455 Posts
        Here is In development board and Quote from: labasus at Feb 07, 2009, 03:47 AM
        it must be good tested before
        wink
          God loves me. 【ツ】


          MODX.ir (Persian Support)

          Boplo.ir/modx/ (Persian)
          • 16545
          • 358 Posts
          What about pagetitle, longtitle, description? Can EasyLingual to convert these standart placeholders?

          EasyLingual ONLY converts [% %] tags in Templates, Page content and page Introtext. NOT in TVs and CHUNKs
            • 33992 ☆ A M B ☆
            • 455 Posts
            EasyLingual ONLY converts [% %] tags in Templates, Page content and page Introtext. NOT in TVs and CHUNKs![/QUOTE]

            If you put [% %] tags in Templates, Page content and page Introtext, it’s not important that what MODx field and tag you use.
              God loves me. 【ツ】


              MODX.ir (Persian Support)

              Boplo.ir/modx/ (Persian)
              • 20413
              • 2,877 Posts
              This is
              A wesome
              H andy
              H opeful
              P rogramming


                @hawproductions | http://mrhaw.com/

                Infograph: MODX Advanced Install in 7 steps:
                http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                • 33992 ☆ A M B ☆
                • 455 Posts
                Quote from: mrhaw at Feb 07, 2009, 06:48 PM

                This is
                A wesome
                H andy
                H opeful
                P rogramming
                Thanks man  smiley
                  God loves me. 【ツ】


                  MODX.ir (Persian Support)

                  Boplo.ir/modx/ (Persian)
                  • 6726
                  • 7,075 Posts
                  Great, I’ll check the plugin out !

                  Tweeted : http://twitter.com/davidm_en/statuses/1189512700
                    .: COO - Commerce Guys - Community Driven Innovation :.


                    MODx est l&#39;outil id
                    • 16545
                    • 358 Posts
                    As I understood, default language setting is for automatic language choose, when the site link ending is without "lang=XX" (XX - some country ISO code).

                    So, I’ve start testing with in 2 languages for example: en, de with [*encontent*] and [*decontent*] TVs, all documents are "uncached".
                    Then my site links are in this way http://domain.tld/site/sitelink.html&lang=en or http://domain.tld/site/sitelink.html&lang=de - every things works fine and content TVs really works.
                    But in case then it just http://domain.tld/site/sitelink.html - [*[%LANG%]content*] has a previous [*content*] value.

                    P.S. One error in Installation description:
                    2. In Configuration tab, copy.paste code below in "plugin configuration" fields
                    &defualt_lang=default language;string; -> must be &default_lang=default language;string;
                      • 20413
                      • 2,877 Posts
                      Then my site links are in this way  http://domain.tld/site/sitelink.html&lang=en or http://domain.tld/site/sitelink.html&lang=de - every things works fine and content TVs really works.
                      But in case then it just http://domain.tld/site/sitelink.html -  [*[%LANG%]content*] has a previous [*content*] value.

                      That means you can use even a third language!? Or am I wrong?  :)
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower