PHP gettext returns input as result in Homestead












0















In a project of our company we use gettext to translate text. This has been working for several years, but now I am trying to run the project in Homestead, everything works fine except gettext. When use for example gettext('input_string') it returns input_string. On our server and in MAMP everything is working fine. What could be the problem? I am running the project on Apache and PHP 7.0 (same as the server and MAMP)



The domain for locales is binded like this:



bindtextdomain('projectname', APPLICATION_PATH. DIRECTORY_SEPARATOR . 'locale');
textdomain('projectname');
bind_textdomain_codeset('projectname', 'UTF-8');


The path in the bindtextdomain is correct. The file structure is:



 - locale
- en_US
- LC_MESSAGES
- projectname.mo
- projectname.po
- fr_FR
- LC_MESSAGES
- projectname.mo
- projectname.po
- nl_NL
- LC_MESSAGES
- projectname.mo
- projectname.po
- pt_PT
- LC_MESSAGES
- projectname.mo
- projectname.po









share|improve this question

























  • Seems gettext() can't find your language files, since it's echoing the input string.

    – Anuga
    Jan 2 at 14:55











  • @Anuga I added the binding and the structue of the language files to the original question

    – Bart Bergmans
    Jan 2 at 15:01











  • missing subfolder in language folders = LC_MESSAGES.

    – Anuga
    Jan 2 at 15:05











  • Whoops sorry, it's there. Just forgot to mention. Updated my question.

    – Bart Bergmans
    Jan 2 at 15:06













  • And you've set, $lang = "en_US"; , putenv("LC_ALL={$lang}"); , setlocale(LC_ALL, $lang); ?

    – Anuga
    Jan 2 at 15:10


















0















In a project of our company we use gettext to translate text. This has been working for several years, but now I am trying to run the project in Homestead, everything works fine except gettext. When use for example gettext('input_string') it returns input_string. On our server and in MAMP everything is working fine. What could be the problem? I am running the project on Apache and PHP 7.0 (same as the server and MAMP)



The domain for locales is binded like this:



bindtextdomain('projectname', APPLICATION_PATH. DIRECTORY_SEPARATOR . 'locale');
textdomain('projectname');
bind_textdomain_codeset('projectname', 'UTF-8');


The path in the bindtextdomain is correct. The file structure is:



 - locale
- en_US
- LC_MESSAGES
- projectname.mo
- projectname.po
- fr_FR
- LC_MESSAGES
- projectname.mo
- projectname.po
- nl_NL
- LC_MESSAGES
- projectname.mo
- projectname.po
- pt_PT
- LC_MESSAGES
- projectname.mo
- projectname.po









share|improve this question

























  • Seems gettext() can't find your language files, since it's echoing the input string.

    – Anuga
    Jan 2 at 14:55











  • @Anuga I added the binding and the structue of the language files to the original question

    – Bart Bergmans
    Jan 2 at 15:01











  • missing subfolder in language folders = LC_MESSAGES.

    – Anuga
    Jan 2 at 15:05











  • Whoops sorry, it's there. Just forgot to mention. Updated my question.

    – Bart Bergmans
    Jan 2 at 15:06













  • And you've set, $lang = "en_US"; , putenv("LC_ALL={$lang}"); , setlocale(LC_ALL, $lang); ?

    – Anuga
    Jan 2 at 15:10
















0












0








0








In a project of our company we use gettext to translate text. This has been working for several years, but now I am trying to run the project in Homestead, everything works fine except gettext. When use for example gettext('input_string') it returns input_string. On our server and in MAMP everything is working fine. What could be the problem? I am running the project on Apache and PHP 7.0 (same as the server and MAMP)



The domain for locales is binded like this:



bindtextdomain('projectname', APPLICATION_PATH. DIRECTORY_SEPARATOR . 'locale');
textdomain('projectname');
bind_textdomain_codeset('projectname', 'UTF-8');


The path in the bindtextdomain is correct. The file structure is:



 - locale
- en_US
- LC_MESSAGES
- projectname.mo
- projectname.po
- fr_FR
- LC_MESSAGES
- projectname.mo
- projectname.po
- nl_NL
- LC_MESSAGES
- projectname.mo
- projectname.po
- pt_PT
- LC_MESSAGES
- projectname.mo
- projectname.po









share|improve this question
















In a project of our company we use gettext to translate text. This has been working for several years, but now I am trying to run the project in Homestead, everything works fine except gettext. When use for example gettext('input_string') it returns input_string. On our server and in MAMP everything is working fine. What could be the problem? I am running the project on Apache and PHP 7.0 (same as the server and MAMP)



The domain for locales is binded like this:



bindtextdomain('projectname', APPLICATION_PATH. DIRECTORY_SEPARATOR . 'locale');
textdomain('projectname');
bind_textdomain_codeset('projectname', 'UTF-8');


The path in the bindtextdomain is correct. The file structure is:



 - locale
- en_US
- LC_MESSAGES
- projectname.mo
- projectname.po
- fr_FR
- LC_MESSAGES
- projectname.mo
- projectname.po
- nl_NL
- LC_MESSAGES
- projectname.mo
- projectname.po
- pt_PT
- LC_MESSAGES
- projectname.mo
- projectname.po






php gettext homestead po






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 15:06







Bart Bergmans

















asked Jan 2 at 14:40









Bart BergmansBart Bergmans

1,58221136




1,58221136













  • Seems gettext() can't find your language files, since it's echoing the input string.

    – Anuga
    Jan 2 at 14:55











  • @Anuga I added the binding and the structue of the language files to the original question

    – Bart Bergmans
    Jan 2 at 15:01











  • missing subfolder in language folders = LC_MESSAGES.

    – Anuga
    Jan 2 at 15:05











  • Whoops sorry, it's there. Just forgot to mention. Updated my question.

    – Bart Bergmans
    Jan 2 at 15:06













  • And you've set, $lang = "en_US"; , putenv("LC_ALL={$lang}"); , setlocale(LC_ALL, $lang); ?

    – Anuga
    Jan 2 at 15:10





















  • Seems gettext() can't find your language files, since it's echoing the input string.

    – Anuga
    Jan 2 at 14:55











  • @Anuga I added the binding and the structue of the language files to the original question

    – Bart Bergmans
    Jan 2 at 15:01











  • missing subfolder in language folders = LC_MESSAGES.

    – Anuga
    Jan 2 at 15:05











  • Whoops sorry, it's there. Just forgot to mention. Updated my question.

    – Bart Bergmans
    Jan 2 at 15:06













  • And you've set, $lang = "en_US"; , putenv("LC_ALL={$lang}"); , setlocale(LC_ALL, $lang); ?

    – Anuga
    Jan 2 at 15:10



















Seems gettext() can't find your language files, since it's echoing the input string.

– Anuga
Jan 2 at 14:55





Seems gettext() can't find your language files, since it's echoing the input string.

– Anuga
Jan 2 at 14:55













@Anuga I added the binding and the structue of the language files to the original question

– Bart Bergmans
Jan 2 at 15:01





@Anuga I added the binding and the structue of the language files to the original question

– Bart Bergmans
Jan 2 at 15:01













missing subfolder in language folders = LC_MESSAGES.

– Anuga
Jan 2 at 15:05





missing subfolder in language folders = LC_MESSAGES.

– Anuga
Jan 2 at 15:05













Whoops sorry, it's there. Just forgot to mention. Updated my question.

– Bart Bergmans
Jan 2 at 15:06







Whoops sorry, it's there. Just forgot to mention. Updated my question.

– Bart Bergmans
Jan 2 at 15:06















And you've set, $lang = "en_US"; , putenv("LC_ALL={$lang}"); , setlocale(LC_ALL, $lang); ?

– Anuga
Jan 2 at 15:10







And you've set, $lang = "en_US"; , putenv("LC_ALL={$lang}"); , setlocale(LC_ALL, $lang); ?

– Anuga
Jan 2 at 15:10














2 Answers
2






active

oldest

votes


















1














The locale wasn't installed on Homestead. Fixed it by using sudo locale-gen nl_NL






share|improve this answer































    -1














    It should work out of the box after installation. Have you restarted Apache? Try first sudo apache2ctl restart or sudo service apache2 restart on the terminal console. If both should not work on your system, try sudo /etc/init.d/apache2 restart.



    Check if there does exist a file /etc/php/7.0/apache2/conf.d/20-gettext.ini (or similar path on your system) containing the line



    extension=gettext.so


    There must not be a semicolon prepended, otherwise it is commented out. Some installations may also configue that line within the basic php configuration file /etc/php/php/7.0/php.ini, however the debian derivate's way is to use extra files in the conf.d folder.



    You can enable PHP modules (e.g. gettext) on the command line



    sudo phpenmod -v 7.0 gettext


    If this does not work, edit the configuration manually.



    Finally restart your Apache service as described above.



    Check also if Apache is running the expected PHP version 7.0 with the following line in your PHP page



    echo phpversion();


    You can enable / disable Apache2 modules from multiple installed PHP versions on the command line



    sudo a2dismod php5
    sudo a2enmod php7.0
    sudo apache2ctl restart





    share|improve this answer



















    • 1





      If it was gettext() not activated in PHP, he would be getting Function not found...

      – Anuga
      Jan 2 at 14:54











    • Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

      – Bart Bergmans
      Jan 2 at 14:56











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008270%2fphp-gettext-returns-input-as-result-in-homestead%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    The locale wasn't installed on Homestead. Fixed it by using sudo locale-gen nl_NL






    share|improve this answer




























      1














      The locale wasn't installed on Homestead. Fixed it by using sudo locale-gen nl_NL






      share|improve this answer


























        1












        1








        1







        The locale wasn't installed on Homestead. Fixed it by using sudo locale-gen nl_NL






        share|improve this answer













        The locale wasn't installed on Homestead. Fixed it by using sudo locale-gen nl_NL







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 10 at 12:18









        Bart BergmansBart Bergmans

        1,58221136




        1,58221136

























            -1














            It should work out of the box after installation. Have you restarted Apache? Try first sudo apache2ctl restart or sudo service apache2 restart on the terminal console. If both should not work on your system, try sudo /etc/init.d/apache2 restart.



            Check if there does exist a file /etc/php/7.0/apache2/conf.d/20-gettext.ini (or similar path on your system) containing the line



            extension=gettext.so


            There must not be a semicolon prepended, otherwise it is commented out. Some installations may also configue that line within the basic php configuration file /etc/php/php/7.0/php.ini, however the debian derivate's way is to use extra files in the conf.d folder.



            You can enable PHP modules (e.g. gettext) on the command line



            sudo phpenmod -v 7.0 gettext


            If this does not work, edit the configuration manually.



            Finally restart your Apache service as described above.



            Check also if Apache is running the expected PHP version 7.0 with the following line in your PHP page



            echo phpversion();


            You can enable / disable Apache2 modules from multiple installed PHP versions on the command line



            sudo a2dismod php5
            sudo a2enmod php7.0
            sudo apache2ctl restart





            share|improve this answer



















            • 1





              If it was gettext() not activated in PHP, he would be getting Function not found...

              – Anuga
              Jan 2 at 14:54











            • Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

              – Bart Bergmans
              Jan 2 at 14:56
















            -1














            It should work out of the box after installation. Have you restarted Apache? Try first sudo apache2ctl restart or sudo service apache2 restart on the terminal console. If both should not work on your system, try sudo /etc/init.d/apache2 restart.



            Check if there does exist a file /etc/php/7.0/apache2/conf.d/20-gettext.ini (or similar path on your system) containing the line



            extension=gettext.so


            There must not be a semicolon prepended, otherwise it is commented out. Some installations may also configue that line within the basic php configuration file /etc/php/php/7.0/php.ini, however the debian derivate's way is to use extra files in the conf.d folder.



            You can enable PHP modules (e.g. gettext) on the command line



            sudo phpenmod -v 7.0 gettext


            If this does not work, edit the configuration manually.



            Finally restart your Apache service as described above.



            Check also if Apache is running the expected PHP version 7.0 with the following line in your PHP page



            echo phpversion();


            You can enable / disable Apache2 modules from multiple installed PHP versions on the command line



            sudo a2dismod php5
            sudo a2enmod php7.0
            sudo apache2ctl restart





            share|improve this answer



















            • 1





              If it was gettext() not activated in PHP, he would be getting Function not found...

              – Anuga
              Jan 2 at 14:54











            • Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

              – Bart Bergmans
              Jan 2 at 14:56














            -1












            -1








            -1







            It should work out of the box after installation. Have you restarted Apache? Try first sudo apache2ctl restart or sudo service apache2 restart on the terminal console. If both should not work on your system, try sudo /etc/init.d/apache2 restart.



            Check if there does exist a file /etc/php/7.0/apache2/conf.d/20-gettext.ini (or similar path on your system) containing the line



            extension=gettext.so


            There must not be a semicolon prepended, otherwise it is commented out. Some installations may also configue that line within the basic php configuration file /etc/php/php/7.0/php.ini, however the debian derivate's way is to use extra files in the conf.d folder.



            You can enable PHP modules (e.g. gettext) on the command line



            sudo phpenmod -v 7.0 gettext


            If this does not work, edit the configuration manually.



            Finally restart your Apache service as described above.



            Check also if Apache is running the expected PHP version 7.0 with the following line in your PHP page



            echo phpversion();


            You can enable / disable Apache2 modules from multiple installed PHP versions on the command line



            sudo a2dismod php5
            sudo a2enmod php7.0
            sudo apache2ctl restart





            share|improve this answer













            It should work out of the box after installation. Have you restarted Apache? Try first sudo apache2ctl restart or sudo service apache2 restart on the terminal console. If both should not work on your system, try sudo /etc/init.d/apache2 restart.



            Check if there does exist a file /etc/php/7.0/apache2/conf.d/20-gettext.ini (or similar path on your system) containing the line



            extension=gettext.so


            There must not be a semicolon prepended, otherwise it is commented out. Some installations may also configue that line within the basic php configuration file /etc/php/php/7.0/php.ini, however the debian derivate's way is to use extra files in the conf.d folder.



            You can enable PHP modules (e.g. gettext) on the command line



            sudo phpenmod -v 7.0 gettext


            If this does not work, edit the configuration manually.



            Finally restart your Apache service as described above.



            Check also if Apache is running the expected PHP version 7.0 with the following line in your PHP page



            echo phpversion();


            You can enable / disable Apache2 modules from multiple installed PHP versions on the command line



            sudo a2dismod php5
            sudo a2enmod php7.0
            sudo apache2ctl restart






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 2 at 14:52









            VitorVitor

            206




            206








            • 1





              If it was gettext() not activated in PHP, he would be getting Function not found...

              – Anuga
              Jan 2 at 14:54











            • Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

              – Bart Bergmans
              Jan 2 at 14:56














            • 1





              If it was gettext() not activated in PHP, he would be getting Function not found...

              – Anuga
              Jan 2 at 14:54











            • Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

              – Bart Bergmans
              Jan 2 at 14:56








            1




            1





            If it was gettext() not activated in PHP, he would be getting Function not found...

            – Anuga
            Jan 2 at 14:54





            If it was gettext() not activated in PHP, he would be getting Function not found...

            – Anuga
            Jan 2 at 14:54













            Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

            – Bart Bergmans
            Jan 2 at 14:56





            Gettext is enabled, also if i check the phpversion(); it says gettext is enabled. And what @Anuga said, the functions are working but not how they should.

            – Bart Bergmans
            Jan 2 at 14:56


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008270%2fphp-gettext-returns-input-as-result-in-homestead%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas