We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12208
    • 3 Posts
    Hello!
    I wan to make a template for distribution.
    and I want to be usable by people in any language.
    http://modx.com/extras/package/xstitchstyle


    This area Can I change the language?
    I can be the setting of the lexicon, but the way to change this area did not know.

    This question has been answered by exside. See the first response.

    [ed. note: hisato last edited this post 12 years, 5 months ago.]
      (๑>◡<๑)
    • discuss.answer
      • 40045
      • 534 Posts
      As far as I can tell this is not possible (unfortunately)...I could make it work when entering an identifier string like

      namespace.lexiconkey into the Caption and Description field when modifing the classfile at manager/controllers/default/resource/resource.class.php around line 380...

              if ($namespace = stristr($tv->get('caption'), '.', true)) {
      
                  $this->modx->lexicon->load($namespace . ':default');
                  if ($this->modx->lexicon(ltrim(stristr($tv->get('caption'), '.'), '.'))) {
                      $tv->set('caption', $this->modx->lexicon(ltrim(stristr($tv->get('caption'), '.'), '.')));
                  }
                  if ($this->modx->lexicon(ltrim(stristr($tv->get('description'), '.'), '.'))) {
                      $tv->set('description', $this->modx->lexicon(ltrim(stristr($tv->get('description'), '.'), '.')));
                  }
              }
              // insert the above code before this line that already exists...
              $tvOutput = $this->fetchTemplate('resource/sections/tvs.tpl');
      


      this is not an option for you though, as you cannot rely on modified core files...sorry...maybe somebody else knows how this currently would already work, but as of here: https://forums.modx.com/thread/31482/multi-language-tv not even Mark knew if this works (I tried, it didn't, so I tried to figure out if this was even possible...will make a PR (EDIT: https://github.com/modxcms/revolution/pull/11394) of this on github, but don't expect it to be in the core soon as this probably much more work... [ed. note: exside last edited this post 12 years, 5 months ago.]
        • 12208
        • 3 Posts
        It was not an easy thing..

        Code you've written will be helpful.
        It's a wonderful!!(>_<)

        I have slightly modified. (?)
        line 380 => 337
        line 289 : foreach ($tvs as $tv) { ... } <= in
        if ($namespace = stristr($tv->get('caption'), '.', true)) {
            $this->modx->lexicon->load($namespace . ':default');
            if ($this->modx->lexicon->exists(ltrim(stristr($tv->get('caption'), '.'), '.'))) {
                $tv->set('caption', $this->modx->lexicon(ltrim(stristr($tv->get('caption'), '.'), '.')));
            }
            if ($this->modx->lexicon->exists(ltrim(stristr($tv->get('description'), '.'), '.'))) {
                $tv->set('description', $this->modx->lexicon(ltrim(stristr($tv->get('description'), '.'), '.')));
            }
        }

        I am glad when it becomes available as this is someday.^^
        Since I have google translate. If I was using a strange word, sorry.
        Thank you!
          (๑>◡<๑)
          • 3749
          • 24,544 Posts
          Hisato, you should know that any time you upgrade MODX, your work will be written over and you will have to do it again.
            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
            • 40045
            • 534 Posts
            Bob is right, core modifications get overridden when upgrading, so keep that in mind =)!

            Two good catches, the code didn't work for all TVs because it wasn't in the foreach loop! And also thanks for making me aware of the $modx->lexion->exists() method! I updated also the use of stristr() to strstr() (as it is possible to specify mixed case namespaces)...updated the PR!
              • 12208
              • 3 Posts
              Quote from: BobRay at May 24, 2014, 12:58 AM
              Hisato, you should know that any time you upgrade MODX, your work will be written over and you will have to do it again.
              Quote from: exside at May 24, 2014, 09:06 AM
              Bob is right, core modifications get overridden when upgrading, so keep that in mind =)!
              OK!
              Thank you very much!
                (๑>◡<๑)