Ejemplo n.º 1
0
<?php

require_once dirname(__FILE__) . 'Localizer.php';
$localizerLanguage = new LocalizerLanguage('locals', 'xx');
$localizerLanguage->setMode('xml');
echo "Add some strings...<br>";
$localizerLanguage->addString("foo", "foo");
$localizerLanguage->addString("bar", "bar");
$localizerLanguage->addString("high", "high");
$localizerLanguage->addString("low", "low");
$localizerLanguage->dumpToHtml();
echo "Add a string in between...<br>";
$localizerLanguage->addString("test", "test", 1);
$localizerLanguage->dumpToHtml();
echo "Update the value of 'test'...<br>";
$success = $localizerLanguage->updateString("test", "test", "***");
if (!$success) {
    echo "ERROR UPDATING VALUE<br>";
}
$localizerLanguage->dumpToHtml();
echo "Update the key for 'test'...<br>";
$success = $localizerLanguage->updateString("test", "test_new");
if (!$success) {
    echo "ERROR UPDATING KEY<br>";
}
$localizerLanguage->dumpToHtml();
echo "Update the key and value for 'test'...<br>";
$success = $localizerLanguage->updateString("test_new", "boo", "ghost");
if (!$success) {
    echo "ERROR UPDATING STRING<br>";
}
Ejemplo n.º 2
0
    /**
     * Move a string from one file to another.
     *
     * @param string $p_oldPrefix
     * @param string $p_newPrefix
     * @param string $p_key
     */
    public static function ChangeStringPrefix($p_oldPrefix, $p_newPrefix, $p_key)
    {
        $languages = Localizer::GetLanguages();
        foreach ($languages as $language) {
			$source = new LocalizerLanguage($p_oldPrefix, $language->getLanguageId());
			$source->loadFile(Localizer::GetMode());
			$srcValue = $source->getValue($p_key);

			$target = new LocalizerLanguage($p_newPrefix, $language->getLanguageId());
			$target->loadFile(Localizer::GetMode());

			$target->addString($p_key, $srcValue);
			$source->deleteString($p_key);

			$target->saveFile(Localizer::GetMode());
			$source->saveFile(Localizer::GetMode());
        }
    } // fn ChangeStringPrefix