We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29988
    • 89 Posts
    Please consider these minor changes.

    First, let me introduce you lang(). It’s easy function:

      function lang($key) { /* returns translation form $lang array. But if it is not present, returns $key - better than nothing! */
        global $_lang;
        if (isset($_lang[$key])) {
          return $_lang[$key];
        } else return $key;
      }


    Function lang() is better than $_lang for obvious reason - when language file is corrupted on incomplete, lang() shows the key. This is much better to handle and search for an error.

    I’ve put lang() in config.inc.php, becouse I didn’t know any better place.

    Now we need to repair site_schedule.static.action.php. This file contains minor errors in translation - englis si hardcoded into PHP. Search for first line of 3 tables and change those static text into lang() calls. After then, it would be something like this:

    <tr bgcolor=’#CCCCCC’>
    <td><?=lang("document");?></td>
    <td><?=lang("id");?></td>
    <td><?=lang("page_data_publishdate");?></td>
    <td><?=lang("page_data_unpublishdate");?></td>
    </tr>
    </thead>

    Please note, that not always all 4 columns are present...

    Now, there is a need for language file to update. Here are few lines from my Czech translation that I’m currently working on. English statements please fill yourself.

    /* Site schedule */
    $_lang["document"] = "Dokument";
    $_lang["id"] = "ID";
    $_lang["publish_events"] = "Nejbližší publikování";
    $_lang["unpublish_events"] = "Nejbližší vrácení";
    $_lang["all_events"] = "Všechny události";
    $_lang["no_docs_pending_unpublishing"]="Žádné dokumenty neèekají na vrácení.";
    $_lang["no_docs_pending_publishing"]="Žádné dokumenty neèekají na publikování.";
    • Thanks for this suggestion, we’ll definitely pick it up in the dev team forums. smiley
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 33175
        • 711 Posts
        It’s a great idea !
        My opinion is not to use this way but to include 2 language files.
        include_once('default_language_file.inc.php');
        include_once('localized_language_file.inc.php');

        On this way, if the string is not translated in the localized_language_file.inc.php, the string value will be picked up the default language file.

        default_language_file.inc.php must be the "core" language file : english I suppose wink

        The same thing can be used for ressources : a default language file (english) and a second (localized). The best will be a Modx core function to call language file.
        Exemple :
        assets
        |_ snippets
        |_NewsListing
        |_ PHP
        |_ language
        |_ NewsListing.en.php
        |_ NewsListing.fr.php

        $modx->loadLanguage("$snippetPath/language/", $lang);


        Best of the best could be used only $modx->loadLanguage(); and Modx manage directory and language localisation.
        It is possible because when snippet is loaded, Modx "knows" that is a snippet and makes create path of the directory language.
        Language localisation can be got because it is configured in the manager.
          Sorry for my english. I&#39;m french... My dictionary is near me, but it&#39;s only a dictionary !