Documentation

GetLanguageCode

Use case for resolving language codes.

Tags
since
3.0.0

Table of Contents

Properties

$repository  : LanguageRepositoryInterface

Methods

__construct()  : mixed
execute()  : string
Try to get language code from its ID.
getLanguageName()  : string
Get language name from its ID.
getScriptDirectionTag()  : string
Return a right-to-left direction indication in HTML if language is RTL.

Properties

Methods

execute()

Try to get language code from its ID.

public execute(int $id, array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}> $languagesTable) : string
Parameters
$id : int

Language ID

$languagesTable : array<string, array{0: string, 1: string, 2: bool, 3: string, 4: string, 5: bool, 6: bool, 7: bool}>

Table of languages, usually from LanguagePresets::getAll()

Return values
string

Two-letter code (e.g., BCP 47) or empty string

getLanguageName()

Get language name from its ID.

public getLanguageName(string|int $id) : string
Parameters
$id : string|int

Language ID

Return values
string

Language name, empty string if not found

getScriptDirectionTag()

Return a right-to-left direction indication in HTML if language is RTL.

public getScriptDirectionTag(string|int|null $id) : string
Parameters
$id : string|int|null

Language ID

Tags
psalm-return

' dir="rtl" '|''

Return values
string

' dir="rtl" ' or empty string


        
On this page

Search results