WebFioriAPI ReferenceLearnDownloadContributeLearn{{result.parent_page}} > {{result.title}}{{result.title}}Classes{{result.class_name}}{{result.summary}}Methods{{result.name}}{{result.summary}}

namespace \webfiori\framework\i18n

class Language

Class Attributes Summary

const DIR_LTRA constant for left to right writing direction.const DIR_RTLA constant for right to left writing direction.

Class Methods Summary

public static function &getLoadedLangs()Returns a reference to an associative array that contains an objects of type 'Language'.public function __construct(string$dir, string$code, array$initials, boolean$addtoLoadedAfterCreate)Creates new instance of the class.public function createAndSet(string$dir, array$labels)Creates a sub-array for defining language variables given initial set of variables.public function createDirectory(string$param)Creates a sub array to define language variables.public function get(string$name)Returns the value of a language variable.public function getCode()Returns the language code that the object represents.public function getLanguageVars()Returns an associative array that contains language variables definition.public function getWritingDir()Returns language writing direction.public function isLoaded()Checks if the language is added to the set of loaded languages or not.public static function loadTranslation(string$langCode)Loads a language file based on language code.public static function reset()Removes all loaded languages.public function set(string$dir, string$varName, string$varValue)Sets or updates a language variable.public function setCode(string$code)Sets the code of the language.public function setMultiple(string$dir, array$arr)Sets multiple language variables.public function setWritingDir(string$dir)Sets language writing direction.public static function unloadTranslation(string$langCode)Unload translation based on its language code.

Class Attributes Details

const DIR_LTRA constant for left to right writing direction. const DIR_RTLA constant for right to left writing direction.

Class Methods Details

public static function &getLoadedLangs()Returns a reference to an associative array that contains an objects of type 'Language'. Returns: arrayThe key of the array represents two characters language code. The index will contain an object of type 'Language'.public function __construct(string$dir, string$code, array$initials, boolean$addtoLoadedAfterCreate)Creates new instance of the class.

Parameters:

  • string $dir 'ltr' or 'rtl'. Default is 'ltr'.
  • string $code Language code (such as 'AR'). Default is 'XX'
  • array $initials An initial array of directories.
  • boolean $addtoLoadedAfterCreate If set to true, the language object that will be created will be added to the set of loaded languages. Default is true.
public function createAndSet(string$dir, array$labels)Creates a sub-array for defining language variables given initial set of variables.

Parameters:

  • string $dir A string that looks like a directory.
  • array $labels An associative array. The key will act as the variable name and the value of the key will act as the variable value.
public function createDirectory(string$param)Creates a sub array to define language variables.

Parameters:

  • string $param A string that looks like a directory. For example, if the given string is 'general', an array with key name 'general' will be created. Another example is if the given string is 'pages/login', two arrays will be created. The top one will have the key value 'pages' and another one inside the pages array with key value 'login'.
public function get(string$name)Returns the value of a language variable.

Parameters:

  • string $name A directory to the language variable (such as 'pages/login/login-label').
Returns: string|arrayIf the given directory represents a label, the function will return its value. If it represents an array, the array will be returned. If nothing was found, the returned value will be the passed value to the function.
public function getCode()Returns the language code that the object represents. Returns: stringLanguage code in upper case (such as 'AR'). If language code is not set, default is returned which is 'XX'.public function getLanguageVars()Returns an associative array that contains language variables definition. Returns: arrayAn associative array that contains language variables definition.public function getWritingDir()Returns language writing direction. Returns: string'ltr' or 'rtl'.public function isLoaded()Checks if the language is added to the set of loaded languages or not. Returns: booleanThe function will return true if the language is added to the set of loaded languages.public static function loadTranslation(string$langCode)Loads a language file based on language code.

Parameters:

  • string $langCode A two digits language code (such as 'ar').
Returns: Languagean object of type 'Language' is returned if the language was loaded.
public static function reset()Removes all loaded languages. public function set(string$dir, string$varName, string$varValue)Sets or updates a language variable. Note that the variable will be set only if the directory does exist.

Parameters:

  • string $dir A string that looks like a directory.
  • string $varName The name of the variable. Note that if the name of the variable is set and it was an array, it will become a string which has the given name and value.
  • string $varValue The value of the variable.
public function setCode(string$code)Sets the code of the language.

Parameters:

  • string $code Language code (such as 'AR').
Returns: booleanThe function will return true if the language code is set. If not set, the function will return false.
public function setMultiple(string$dir, array$arr)Sets multiple language variables.

Parameters:

  • string $dir A string that looks like a directory.
  • array $arr An associative array. The key will act as the variable name and the value of the key will act as the variable value. The value can be a sub associative array of labels or simple strings.
public function setWritingDir(string$dir)Sets language writing direction.

Parameters:

  • string $dir 'ltr' or 'rtl'. Letters case does not matter.
Returns: booleanThe function will return true if the language writing direction is updated. The only case that the function will return false is when the writing direction is invalid ( Any value other than 'ltr' and 'rtl').
public static function unloadTranslation(string$langCode)Unload translation based on its language code.

Parameters:

  • string $langCode A two digits language code (such as 'ar').
Returns: booleanIf the translation file was unloaded, the method will return true. If not, the method will return false.
mdi-menuAll Classesmdi-chevron-leftAnchorBrCodeSnippetHTMLDocHTMLListHTMLNodeHTMLTableHeadNodeInputJsCodeLabelListItemOrderedListParagraphRadioGroupTableCellTableRowUnorderedListInvalidNodeNameExceptionTemplateNotFoundExceptionCaseConverterJsonJsonConverterJsonIJsonTypesPropertyAPIFilterAbstractWebServiceManagerInfoServiceParamTypesRequestRequestParameterResponseUriWebServicesManagerAccessAutoLoaderConfigConfigControllerDBEAbstractWebServiceExtendedWebServicesManagerFileLoggerPrivilegePrivilegesGroupThemeThemeLoaderUploadFileUploaderUserUtilWebFioriAppLanguageErrorBoxHTTPCodeViewMessageBoxServerErrViewStarterPageWebPageDatabaseSessionStorageDefaultSessionStorageMSSQLSessionDataTableMSSQLSessionsTableMySQLSessionDataTableMySQLSessionsTableSessionSessionOperationsSessionStorageSessionsManagerRouterRouterUriAbstractMiddlewareMiddlewareManagerEmailMessageSMTPAccountSMTPServerClassLoaderExceptionFileExceptionInitializationExceptionInvalidCRONExprExceptionMissingLangExceptionNoSuchThemeExceptionRoutingExceptionSMTPExceptionSessionExceptionUIExceptionAbstractJobCronCronEmailCronJobJobArgumentCronLoginViewCronTasksViewCronViewCronLoginServiceCronLogoutServiceCronServicesManagerForceCronExecutionServiceGetJobsServiceCLICLICommandInputStreamOutputStreamStdInStdOutClassWriterLangClassWriterQueryClassWriterServiceHolderThemeClassWriterWebServiceWriterCreateCLIClassHelperCreateCronJobCreateMiddlewareCreateTableCreateTableObjCreateThemeHelperCreateWebServiceAddCommandCreateCommandCronCommandHelpCommandListCronCommandListRoutesCommandListThemesCommandRunSQLQueryCommandSettingsCommandTestRouteCommandUpdateSettingsCommandUpdateTableCommandVersionCommandAbstractQueryColumnColumnFactoryConditionConnectionConnectionInfoDatabaseDatabaseExceptionDateTimeValidatorEntityMapperExpressionForeignKeyJoinTableResultSetSelectExpressionTableWhereExpressionMySQLColumnMySQLConnectionMySQLQueryMySQLTableMSSQLColumnMSSQLConnectionMSSQLQueryMSSQLTableAbstractCollectionComparableLinkedListNodeQueueStack
Powered By: WebFiori Framework, Vue and VuetifyAll Rights Reserved © 2018 - 2024