We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26074
    • 121 Posts
    How I can set the date generated by ditto 2 in my language, for example in italian?

    I should use the
    setlocale(LC_ALL, "it_IT");


    Where to put this?
      ___________________________________________________________________
      ..:: Samuele ::..
      • 1511
      • 144 Posts
      For Ditto use parameter &dateFormat=`%d.%m.%y, %H:%M`. This way you can format the date any way you like it.
      Other option is to execute setlocale anywhere prior the snippet execution.
      Though it won’t work if the snippet uses its own date formatting functions.

      I put my setlocale directly in snippet code or snippet language file.
        • 26074
        • 121 Posts
        I call this in my news page

        [[data-it]]
        {{news}}
        


        The chunk {{news}} is
        [!Ditto? &language=`italian` &tpl=`template-ditto` &parents=`[*id*]` &total=`all` &display=`4` &paginate=`1` &paginateAlwaysShowLinks=`1` &dateSource=`pub_date` &dateFormat=`%d %B %Y` !]
        


        and the snippet [[data-it]] is
        <?php
        setlocale(LC_ALL, "it_IT");
        //setlocale(LC_TIME,"it_IT");
        ?>
        


        The output is always a date in english sad
          ___________________________________________________________________
          ..:: Samuele ::..
          • 18397
          • 3,250 Posts
          Put setlocale(LC_ALL, "it_IT"); in the italian language file.
            • 26074
            • 121 Posts
            I try, but don’t work.
              ___________________________________________________________________
              ..:: Samuele ::..
              • 26074
              • 121 Posts
              I try also to put the
              setlocale(LC_ALL, "it_IT"); 
              in Ditto snippet directly, but nothing.

              Other solution? huh
                ___________________________________________________________________
                ..:: Samuele ::..
                • 1511
                • 144 Posts
                Can you create a manager user for me, so I can take a look?
                I cannot understand what’s going on.
                  • 26074
                  • 121 Posts
                  Mmm... the site is on localhost (vers. modx 0.9.5 - Ditto 2.0.2)


                  My problem is the date. For example, now the date is show as: "by Administrator on 11 April 2007".
                  Instead I want "by Administrator on 11 Aprile 2007". April in italian.

                    ___________________________________________________________________
                    ..:: Samuele ::..
                    • 30223
                    • 1,010 Posts
                    Is your server running on Windows? If so, you may need to use a different language string. Setlocale is platform dependend. Try this:

                    setlocale(LC_ALL, 'it_IT', 'ita, 'italian');

                      • 26074
                      • 121 Posts
                      Yes, my server running on Windows.
                      With your code it works. Thanks. smiley
                        ___________________________________________________________________
                        ..:: Samuele ::..