Nextcloud PHP API (master)

IFactory

Tags
since
8.2.0

Table of Contents

Methods

findAvailableLanguages()  : array<string|int, string>
Find all available languages for an app
findAvailableLocales()  : array<string|int, mixed>
findGenericLanguage()  : string
Try to find the best language for generic tasks
findLanguage()  : string
Find the best language for the context of the current user
findLanguageFromLocale()  : null|string
find the matching lang from the locale
findLocale()  : string
get()  : IL10N
Get a language instance
getLanguageDirection()  : "ltr"|"rtl"
Return the language direction
getLanguageIterator()  : ILanguageIterator
iterate through language settings (if provided) in this order: 1. returns the forced language or: 2. if applicable, the trunk of 1 (e.g. "fu" instead of "fu_BAR" 3. returns the user language or: 4. if applicable, the trunk of 3 5. returns the system default language or: 6. if applicable, the trunk of 5 7+∞. returns 'en'
getLanguages()  : array<string|int, mixed>
returns the common language and other languages in an associative array
getUserLanguage()  : string
Return the language to use when sending something to a user
languageExists()  : bool
localeExists()  : bool

Methods

findAvailableLanguages()

Find all available languages for an app

public findAvailableLanguages([string|null $app = null ]) : array<string|int, string>
Parameters
$app : string|null = null

App id or null for core

Tags
since
9.0.0
Return values
array<string|int, string>

an array of available languages

findAvailableLocales()

public findAvailableLocales() : array<string|int, mixed>
Tags
since
14.0.0
Return values
array<string|int, mixed>

an array of available

findGenericLanguage()

Try to find the best language for generic tasks

public findGenericLanguage([string|null $appId = null ]) : string

This method will try to find the most generic language based on system settings, independent of the user logged into the current process. This is useful for tasks that are run for another user. E.g. the current user sends an email to someone else, then we don't want the current user's language to be picked but rather a instance-wide default that likely fits the target user

Parameters
$appId : string|null = null

specify if you only want a language a specific app supports

Tags
since
23.0.0
Return values
string

language code, defaults to 'en' if no other matches are found

findLanguage()

Find the best language for the context of the current user

public findLanguage([string|null $appId = null ]) : string

This method will try to find the most specific language based on info from the user who is logged into the current process and will fall back to system settings and heuristics otherwise.

Parameters
$appId : string|null = null

specify if you only want a language a specific app supports

Tags
since
9.0.0
Return values
string

language code, defaults to 'en' if no other matches are found

findLanguageFromLocale()

find the matching lang from the locale

public findLanguageFromLocale([string $app = 'core' ][, string $locale = null ]) : null|string
Parameters
$app : string = 'core'
$locale : string = null
Tags
since
14.0.1
Return values
null|string

findLocale()

public findLocale([string|null $lang = null ]) : string
Parameters
$lang : string|null = null

user language as default locale

Tags
since
14.0.0
Return values
string

locale If nothing works it returns 'en_US'

get()

Get a language instance

public get(string $app[, string|null $lang = null ][, string|null $locale = null ]) : IL10N
Parameters
$app : string
$lang : string|null = null
$locale : string|null = null
Tags
since
8.2.0
Return values
IL10N

getLanguageDirection()

Return the language direction

public getLanguageDirection(string $language) : "ltr"|"rtl"
Parameters
$language : string
Tags
since
31.0.0
Return values
"ltr"|"rtl"

getLanguageIterator()

iterate through language settings (if provided) in this order: 1. returns the forced language or: 2. if applicable, the trunk of 1 (e.g. "fu" instead of "fu_BAR" 3. returns the user language or: 4. if applicable, the trunk of 3 5. returns the system default language or: 6. if applicable, the trunk of 5 7+∞. returns 'en'

public getLanguageIterator([IUser|null $user = null ]) : ILanguageIterator

Hint: in most cases findLanguage() suits you fine

Parameters
$user : IUser|null = null
Tags
since
14.0.0
Return values
ILanguageIterator

getLanguages()

returns the common language and other languages in an associative array

public getLanguages() : array<string|int, mixed>
Tags
since
23.0.0
Return values
array<string|int, mixed>

getUserLanguage()

Return the language to use when sending something to a user

public getUserLanguage([IUser|null $user = null ]) : string
Parameters
$user : IUser|null = null
Tags
since
20.0.0
Return values
string

languageExists()

public languageExists(string|null $app, string $lang) : bool
Parameters
$app : string|null

App id or null for core

$lang : string
Tags
since
9.0.0
Return values
bool

localeExists()

public localeExists(string $locale) : bool
Parameters
$locale : string
Tags
since
14.0.0
Return values
bool

        
On this page

Search results