ZFFramework
 
Loading...
Searching...
No Matches
ZFAppLang.h File Reference

helper for quickly update app lang More...

#include "ZFAppUtilDef.h"

Go to the source code of this file.

Classes

class  ZFAppLangData
 lang info for ZFAppLangList More...
 

Functions

zfautoT< ZFArrayZFAppLangList (const ZFPathInfo &base=(zft_zfnull), zfbool enableCache=(_ZFT_t_zftrue))
 get a list of supported lang
 
zfautoT< ZFTaskIdZFAppLangLoad (const zfstring &langId=(zft_zfnull), const ZFListener &finishCallback=(zft_zfnull), const ZFPathInfo &base=(zft_zfnull), zfbool enableCache=(_ZFT_t_zftrue))
 see ZFAppLangList
 
zfstring ZFAppLang ()
 see ZFAppLangList
 
zfautoT< ZFTaskZFAppLangLoadTask (const zfstring &langId=(zft_zfnull), const ZFPathInfo &base=(zft_zfnull), zfbool enableCache=(_ZFT_t_zftrue))
 util to create a task for ZFAppLangLoad
 

Detailed Description

helper for quickly update app lang

Function Documentation

◆ ZFAppLangList()

zfautoT< ZFArray > ZFAppLangList ( const ZFPathInfo & base = (zft_zfnull),
zfbool enableCache = (_ZFT_t_zftrue) )
extern

get a list of supported lang

how it works:

  1. you should prepare your lang files in lang dir of ZFPathType_res
  2. the lang files' file name should match this rule:
    • <langId>.* file, e.g. lang/your_lang_id.xml or lang/your_lang_id.xxx.xml
    • <langId>.* dir, e.g. lang/your_lang_id/ or lang/your_lang_id.xxx/
    • specially:
      • lang/default.* file or lang/default.* dir would be loaded before loading each lang
      • lang/config.* file would be loaded to detect each lang names for display, with this format:
        <zfstring prop="langName_<langId>" value="<langName>" />
        <zfstring prop="langName_your_lang_id" value="YourLangName" />
        ...
        zft_zfstring< zfchar > zfstring
        see zft_zfstring
        Definition ZFCoreTypeDef_StringType.h:15
        see ZFStyleLoad
        Definition ZFStyleLoad.h:44
  3. ZFStyleLoadAsync would be called to load the lang files

typical usage:

// list available lang
// get current lang, empty for default
// let user to choose,
// or fallback to use default
zfstring desired = xxx;
// change lang, empty for default lang
// the desired lang would be saved to #ZFState,
// and would be applied when next time app launch with #ZFAppLangInit
ZFAppLangLoad(desired);
// use the lang as #ZFStyleable::propStyle
ZFUITextView *v = xxx;
v->propStyle("text", "some_style_key");
zfautoT< ZFTaskId > ZFAppLangLoad(const zfstring &langId=(zft_zfnull), const ZFListener &finishCallback=(zft_zfnull), const ZFPathInfo &base=(zft_zfnull), zfbool enableCache=(_ZFT_t_zftrue))
see ZFAppLangList
zfstring ZFAppLang()
see ZFAppLangList
zfautoT< ZFArray > ZFAppLangList(const ZFPathInfo &base=(zft_zfnull), zfbool enableCache=(_ZFT_t_zftrue))
get a list of supported lang
void propStyle(const zfstring &propertyName, const zfstring &styleKey)
see ZFStyleSet
view to display plain text
Definition ZFUITextView.h:21
type restrict version of zfauto
Definition zfautoFwd.h:108

◆ ZFAppLangLoad()

zfautoT< ZFTaskId > ZFAppLangLoad ( const zfstring & langId = (zft_zfnull),
const ZFListener & finishCallback = (zft_zfnull),
const ZFPathInfo & base = (zft_zfnull),
zfbool enableCache = (_ZFT_t_zftrue) )
extern

see ZFAppLangList

empty langId would load previous ZFAppLang stored in ZFState
finishCallback's param0 would be a v_ZFResultType indicates result