Skip to content

Commit

Permalink
rename "Lang" to "Locale", as requested by gauthierm
Browse files Browse the repository at this point in the history
  • Loading branch information
cweiske committed Jun 4, 2012
1 parent b541328 commit a036f39
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions src/Date/HumanDiff.php
Expand Up @@ -212,13 +212,13 @@ protected function getTranslation($string)
*
* @return void
*/
public function setTranslator(Date_HumanDiff_Lang $translator)
public function setTranslator(Date_HumanDiff_Locale $translator)
{
$this->translator = $translator;
}

/**
* Set the language to use.
* Set the locale to use.
*
* Supported formats:
* - 2-letter ISO code ("de", "fr")
Expand All @@ -228,7 +228,7 @@ public function setTranslator(Date_HumanDiff_Lang $translator)
*
* @return boolean True if the translations could be loaded, false if not.
*/
public function setLanguage($lang)
public function setLocale($lang)
{
if (strlen($lang) > 2) {
//split off encoding
Expand All @@ -239,15 +239,15 @@ public function setLanguage($lang)
$lang = $locale;
}

$class = 'Date_HumanDiff_Lang_' . $lang;
$class = 'Date_HumanDiff_Locale_' . $lang;
$file = str_replace('_', '/', $class) . '.php';
if ($this->isIncludable($file)) {
include_once $file;
}
if (!class_exists($class)) {
if (strlen($lang) > 2) {
//try main language without country
return $this->setLanguage(substr($lang, 0, 2));
return $this->setLocale(substr($lang, 0, 2));
}
return false;
}
Expand Down
@@ -1,6 +1,6 @@
<?php

interface Date_HumanDiff_Lang
interface Date_HumanDiff_Locale
{
/**
* Get the translation for the given string.
Expand Down
@@ -1,7 +1,7 @@
<?php
require_once 'Date/HumanDiff/LangArray.php';
require_once 'Date/HumanDiff/LocaleArray.php';

class Date_HumanDiff_Lang_de extends Date_HumanDiff_LangArray
class Date_HumanDiff_Locale_de extends Date_HumanDiff_LocaleArray
{
/**
* Translation array.
Expand Down
@@ -1,7 +1,7 @@
<?php
require_once 'Date/HumanDiff/Lang.php';
require_once 'Date/HumanDiff/Locale.php';

abstract class Date_HumanDiff_LangArray implements Date_HumanDiff_Lang
abstract class Date_HumanDiff_LocaleArray implements Date_HumanDiff_Locale
{
/**
* Get the translation for the given string.
Expand Down
16 changes: 8 additions & 8 deletions tests/Date/HumanDiffTest.php
Expand Up @@ -97,27 +97,27 @@ public function testGetStringDateTime()
);
}

public function testSetLanguageExisting()
public function testSetLocaleExisting()
{
$this->assertTrue($this->dh->setLanguage('de'));
$this->assertTrue($this->dh->setLocale('de'));
$this->assertEquals('gerade eben', $this->dh->get(time()));
}

public function testSetLanguageParentExisting()
public function testSetLocaleParentExisting()
{
$this->assertTrue($this->dh->setLanguage('de_AT'));
$this->assertTrue($this->dh->setLocale('de_AT'));
$this->assertEquals('gerade eben', $this->dh->get(time()));
}

public function testSetLanguageNotExisting()
public function testSetLocaleNotExisting()
{
$this->assertFalse($this->dh->setLanguage('mg'));
$this->assertFalse($this->dh->setLocale('mg'));
$this->assertEquals('just now', $this->dh->get(time()));
}

public function testSetLanguageInvalid()
public function testSetLocaleInvalid()
{
$this->assertFalse($this->dh->setLanguage('/path/to/some/file.php'));
$this->assertFalse($this->dh->setLocale('/path/to/some/file.php'));
$this->assertEquals('just now', $this->dh->get(time()));
}

Expand Down

0 comments on commit a036f39

Please sign in to comment.