Help to localization
Project description
install
pip3 install langful
or pip install langful
get start
lang file
ps:
langful
load json file firstor you can set to
langful.lang( json_first = False )
.json
{
"key": "value" ,
"..." : "..."
}
.lang
if you need highlight, you can install
vscode-langful
: GitHub VSCode
key = value # hi, this is a example
# hi, I am a example, too
... = ...
init
there have two
ways to init
by files
import langful
lang = langful.lang()
then you can put file at there :
- lang
-
- en_us.lang
-
- en_us.json
-
- zh_cn.lang
-
- zh_cn.json
or use other directory name and set langful.lang( "directory name" )
by dictionary
import langful
lang = langful.lang( False )
lang.init_dict( {
"en_us" : {
"hi" : "Hi" ,
"welcome" : "Welcome"
} ,
"zh_cn" : {
"hi" : "你好" ,
"welcome" : "欢迎"
}
} )
function
replace
lang = langful.lang( False )
lang.replace_letter = "&"
lang.init_dict( {
"en_us" : {
"test" : "&.&%"
}
} )
print( lang.replace( "test" , [ 33 , 3 ] ) )
replace str
import langful
lang = langful.lang( False )
lang.init_dict( {
"en_us" : {
"hi" : "Hi" ,
"welcome" : "Welcome"
} ,
"zh_cn" : {
"hi" : "你好" ,
"welcome" : "欢迎"
}
} )
print(lang.replace_str( "%hi%, %welcome%!" ))
merge
import langful
lang = langful.lang( False )
lang.init_dict( {
"en_us" : {
"hi" : "Hi" ,
"welcome" : "Welcome"
} ,
"zh_cn" : {
"hi" : "你好"
}
} )
print( lang.merge( "en_us" , [ "zh_cn" ] ) )
about
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
langful-0.32-py3-none-any.whl
(5.4 kB
view hashes)