Heratio Framework API Reference

LanguageService
in package

Language Service.

Handles language code conversion between:

  • ISO 639-1 (2-letter): Used by AtoM (en, af, zu)
  • ISO 639-2 (3-letter): Used by book APIs (eng, afr, zul)

Table of Contents

Methods

findByCode()  : object|null
Find language term by ISO 639-1 code.
findByName()  : object|null
Find language term by name.
getAll()  : Collection
Get all languages from database.
getCodeFromName()  : string|null
Get language code from name.
getNameFromCode()  : string
Get language name from any ISO code (2 or 3 letter).
getNameFromIsoCode()  : string
Alias for getNameFromCode.
getTermIdFromCode()  : int|null
Get term ID for a language code.
iso639_1to2()  : string
Convert ISO 639-1 (2-letter) to ISO 639-2 (3-letter).
iso639_2to1()  : string
Convert ISO 639-2 (3-letter) to ISO 639-1 (2-letter).

Methods

findByCode()

Find language term by ISO 639-1 code.

public static findByCode(string $code[, string $culture = 'en' ]) : object|null

AtoM stores languages with 2-letter codes in the term name or as the culture.

Parameters
$code : string
$culture : string = 'en'
Return values
object|null

findByName()

Find language term by name.

public static findByName(string $name[, string $culture = 'en' ]) : object|null
Parameters
$name : string
$culture : string = 'en'
Return values
object|null

getAll()

Get all languages from database.

public static getAll([string $culture = 'en' ]) : Collection
Parameters
$culture : string = 'en'
Return values
Collection

getCodeFromName()

Get language code from name.

public static getCodeFromName(string $name) : string|null
Parameters
$name : string
Return values
string|null

getNameFromCode()

Get language name from any ISO code (2 or 3 letter).

public static getNameFromCode(string $code[, string $culture = 'en' ]) : string
Parameters
$code : string
$culture : string = 'en'
Return values
string

getNameFromIsoCode()

Alias for getNameFromCode.

public static getNameFromIsoCode(string $code[, string $culture = 'en' ]) : string
Parameters
$code : string
$culture : string = 'en'
Return values
string

getTermIdFromCode()

Get term ID for a language code.

public static getTermIdFromCode(string $code[, string $culture = 'en' ]) : int|null
Parameters
$code : string
$culture : string = 'en'
Return values
int|null

iso639_1to2()

Convert ISO 639-1 (2-letter) to ISO 639-2 (3-letter).

public static iso639_1to2(string $code) : string
Parameters
$code : string
Return values
string

iso639_2to1()

Convert ISO 639-2 (3-letter) to ISO 639-1 (2-letter).

public static iso639_2to1(string $code) : string
Parameters
$code : string
Return values
string

        
On this page

Search results