Factory

class OC\L10N\Factory
A factory that generates language instances
Source:lib/private/L10N/Factory.php#50
Implements:OCP\L10N\IFactory

Constants

COMMON_LANGUAGE_CODES = [en, es, fr, de, de_DE, ja, ar, ru, nl, it, pt_BR, pt_PT, da, fi_FI, nb_NO, sv, tr, zh_CN, ko]
Source:lib/private/L10N/Factory.php#81

Properties

protected static property OC\L10N\Factory::$requestLanguage
Source:lib/private/L10N/Factory.php#53
Type:string
protected static property OC\L10N\Factory::$instances
cached instances
Source:lib/private/L10N/Factory.php#59
Type:array Structure: Lang => App => \OCP\IL10N
protected static property OC\L10N\Factory::$availableLanguages
Source:lib/private/L10N/Factory.php#64
Type:array Structure: App => string[]
protected static property OC\L10N\Factory::$localeCache
Source:lib/private/L10N/Factory.php#69
Type:array
protected static property OC\L10N\Factory::$availableLocales
Source:lib/private/L10N/Factory.php#74
Type:array
protected static property OC\L10N\Factory::$pluralFunctions
Source:lib/private/L10N/Factory.php#79
Type:array Structure: string => callable
protected static property OC\L10N\Factory::$config
Source:lib/private/L10N/Factory.php#87
Type:\OCP\IConfig
protected static property OC\L10N\Factory::$request
Source:lib/private/L10N/Factory.php#90
Type:\OCP\IRequest
protected static property OC\L10N\Factory::$userSession
Source:lib/private/L10N/Factory.php#93
Type:\OCP\IUserSession
protected static property OC\L10N\Factory::$serverRoot
Source:lib/private/L10N/Factory.php#96
Type:string

Methods

public OC\L10N\Factory::__construct($config, $request, $userSession, $serverRoot)
Source:

lib/private/L10N/Factory.php#104

Parameters:
public OC\L10N\Factory::get($app, $lang=null, $locale=null)
Get a language instance
Source:

lib/private/L10N/Factory.php#122

Parameters:
  • $app (string)
  • $lang (string | null)
  • $locale (string | null)
Returns:

\OCP\IL10N

public OC\L10N\Factory::findLanguage($app=null)
Find the best language
Source:

lib/private/L10N/Factory.php#164

Parameters:
  • $app (string | null) App id or null for core
Returns:

string language If nothing works it returns ‘en’

public OC\L10N\Factory::findLocale($lang=null)
find the best locale
Source:

lib/private/L10N/Factory.php#225

Parameters:
  • $lang (string)
Returns:

null | string

public OC\L10N\Factory::findLanguageFromLocale($app=core, $locale=null)
find the matching lang from the locale
Source:

lib/private/L10N/Factory.php#268

Parameters:
  • $app (string)
  • $locale (string)
Returns:

null | string

public OC\L10N\Factory::findAvailableLanguages($app=null)
Find all available languages for an app
Source:

lib/private/L10N/Factory.php#286

Parameters:
  • $app (string | null) App id or null for core
Returns:

array an array of available languages

public OC\L10N\Factory::findAvailableLocales()
Source:lib/private/L10N/Factory.php#334
Returns:array | mixed
public OC\L10N\Factory::languageExists($app, $lang)
Source:

lib/private/L10N/Factory.php#350

Parameters:
  • $app (string | null) App id or null for core
  • $lang (string)
Returns:

bool

public OC\L10N\Factory::getLanguageIterator($user=null)
Source:lib/private/L10N/Factory.php#359
public OC\L10N\Factory::getUserLanguage($user=null)
Return the language to use when sending something to a user
Source:

lib/private/L10N/Factory.php#374

Parameters:
Returns:

string

Since:

20.0.0

public OC\L10N\Factory::localeExists($locale)
Source:

lib/private/L10N/Factory.php#394

Parameters:
  • $locale (string)
Returns:

bool

protected OC\L10N\Factory::respectDefaultLanguage($app, $lang)
if default language is set to de_DE (formal German) this should be
preferred to ‘de’ (non-formal German) if possible
Source:

lib/private/L10N/Factory.php#453

Parameters:
  • $app (string | null)
  • $lang (string)
Returns:

string

public OC\L10N\Factory::getL10nFilesForApp($app, $lang)
Source:lib/private/L10N/Factory.php#500
protected OC\L10N\Factory::findL10nDir($app=null)
find the l10n directory
Source:

lib/private/L10N/Factory.php#533

Parameters:
  • $app (string) App id or empty string for core
Returns:

string directory

public OC\L10N\Factory::createPluralFunction($string)
Creates a function from the plural string
Parts of the code is copied from Habari:
Source:

lib/private/L10N/Factory.php#554

Parameters:
  • $string (string)
Returns:

string

public OC\L10N\Factory::getLanguages()
returns the common language and other languages in an
associative array
Source:lib/private/L10N/Factory.php#616
Returns:array