A function which has an object and a locale as parameter.
- The object holds an array of translations
->getTranslations()
and->getTranslation($locale)
are available - Locale is a dead simple string of 2 chars
- The function has access to an array of locales ordered by priority
- The locale parameter should be priority #1, otherwise the array of priorities is used to get the correct locale.
class Testing {
private $localePriorityArray = ['nl', 'en', 'fr', 'de'];
public function functionName($object, $locale = 'en')
{
// $object->getTranslation($locale); (null if not available)
// return the translation
}
}
Give it a go on: http://3v4l.org
I'd use recursion