Skip to content

Instantly share code, notes, and snippets.

@dineshghule321
Forked from bosskovic/I18n_test.php
Last active February 20, 2018 03:58
Show Gist options
  • Select an option

  • Save dineshghule321/20ee920218ae31a8a2acb737cf416b58 to your computer and use it in GitHub Desktop.

Select an option

Save dineshghule321/20ee920218ae31a8a2acb737cf416b58 to your computer and use it in GitHub Desktop.

Revisions

  1. dineshghule321 revised this gist Feb 20, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@
    echo _("We connect developers and translators around the globe
    on Lingohub for a fantastic localization experience.");

    echo sprintf(_('Welcome back, %1$s! Your last visit was on %2$s', $user, date('l'));
    echo sprintf(_('Welcome back, %1$s! Your last visit was on %2$s', $user, date('l')));

    // dgettext() is similar to _(), but it also accepts a domain name if a string from
    // a domain other the one set by textdomain() needs to be displayed
  2. Marko Bošković revised this gist Jul 7, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -37,4 +37,8 @@
    // dgettext() is similar to _(), but it also accepts a domain name if a string from
    // a domain other the one set by textdomain() needs to be displayed
    echo dgettext("example2", "");

    // ngettext() is used when the plural form of the message is dependent on the count
    echo ngettext("%d page read.", "%d pages read.", 1); //outputs a form used for singular
    echo ngettext("%d page read.", "%d pages read.", 15); //outputs a form used when the count is 15
    ?>
  3. Marko Bošković revised this gist Jul 7, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -21,6 +21,10 @@

    textdomain($domain);

    $domain2 = "example2";
    bindtextdomain($domain2, "Locale");
    bind_textdomain_codeset($domain2, 'UTF-8');

    $user = "Curious gettext tester";

    // _() is an alias of gettext()
  4. Marko Bošković revised this gist Jul 7, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,8 @@

    // _() is an alias of gettext()
    echo _("Let’s make the web multilingual.");
    echo _("We connect developers and translators around the globe \non Lingohub for a fantastic localization experience.");
    echo _("We connect developers and translators around the globe
    on Lingohub for a fantastic localization experience.");

    echo sprintf(_('Welcome back, %1$s! Your last visit was on %2$s', $user, date('l'));

  5. Marko Bošković revised this gist Jul 7, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,13 @@

    $user = "Curious gettext tester";

    // _() is an alias of gettext()
    echo _("Let’s make the web multilingual.");
    echo _("We connect developers and translators around the globe \non Lingohub for a fantastic localization experience.");

    echo sprintf(_('Welcome back, %1$s! Your last visit was on %2$s', $user, date('l'));

    // dgettext() is similar to _(), but it also accepts a domain name if a string from
    // a domain other the one set by textdomain() needs to be displayed
    echo dgettext("example2", "");
    ?>
  6. Marko Bošković revised this gist Jul 7, 2013. 1 changed file with 14 additions and 3 deletions.
    17 changes: 14 additions & 3 deletions I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,18 @@
    <?php
    $language = "de";
    putenv("LANG=" . $language);
    setlocale(LC_ALL, $language);
    session_start();

    if (isset($_GET["locale"])) {
    $locale = $_GET["locale"];
    }
    else if (isset($_SESSION["locale"])) {
    $locale = $_SESSION["locale"];
    }
    else {
    $locale = "en_UK";
    }

    putenv("LANG=" . $locale);
    setlocale(LC_ALL, $locale);


    $domain = "example";
  7. Marko Bošković revised this gist Jul 5, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -15,5 +15,4 @@
    echo _("Let’s make the web multilingual.");
    echo _("We connect developers and translators around the globe \non Lingohub for a fantastic localization experience.");
    echo sprintf(_('Welcome back, %1$s! Your last visit was on %2$s', $user, date('l'));
    ));
    ?>
  8. Marko Bošković revised this gist Jul 5, 2013. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -14,8 +14,6 @@

    echo _("Let’s make the web multilingual.");
    echo _("We connect developers and translators around the globe \non Lingohub for a fantastic localization experience.");
    echo $this->lang->_trans('Welcome back, %1$s! Your last visit was on %2$s', array(
    'u' => $user,
    'd' => date('l')
    echo sprintf(_('Welcome back, %1$s! Your last visit was on %2$s', $user, date('l'));
    ));
    ?>
  9. Marko Bošković revised this gist Jul 5, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@

    echo _("Let’s make the web multilingual.");
    echo _("We connect developers and translators around the globe \non Lingohub for a fantastic localization experience.");
    echo $this->lang->_trans('Welcome back, %u! Your last visit was on %d', array(
    echo $this->lang->_trans('Welcome back, %1$s! Your last visit was on %2$s', array(
    'u' => $user,
    'd' => date('l')
    ));
  10. Marko Bošković created this gist Jul 5, 2013.
    21 changes: 21 additions & 0 deletions I18n_test.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <?php
    $language = "de";
    putenv("LANG=" . $language);
    setlocale(LC_ALL, $language);


    $domain = "example";
    bindtextdomain($domain, "Locale");
    bind_textdomain_codeset($domain, 'UTF-8');

    textdomain($domain);

    $user = "Curious gettext tester";

    echo _("Let’s make the web multilingual.");
    echo _("We connect developers and translators around the globe \non Lingohub for a fantastic localization experience.");
    echo $this->lang->_trans('Welcome back, %u! Your last visit was on %d', array(
    'u' => $user,
    'd' => date('l')
    ));
    ?>