Skip to main content

provides internationalization for python

Project description

langful

PyPI version Python version license Github stars Github issues

[ en_us | zh_cn ]


install

pip3 install langful or pip install langful

get start

lang file

ps: langful load json file first

or 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( {
    "en_us" : {
        "hi" : "Hi" ,
        "welcome" : "Welcome"
    } ,
    "zh_cn" : {
        "hi" : "你好" ,
        "welcome" : "欢迎"
    }
} )

function

replace

lang = langful.lang( {
    "en_us" : {
        "test" : "{}.{}%"
    }
} )
print( lang.replace( "test" , [ 33 , 3 ] ) )

merge

import langful
lang = langful.lang( {
    "en_us" : {
        "hi" : "Hi" ,
        "welcome" : "Welcome"
    } ,
    "zh_cn" : {
        "hi" : "你好"
    }
} )
print( lang.merge( "en_us" , [ "zh_cn" ] ) )

about

[ github | pypi ]

Project details


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.46-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page