Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
PyUniversalize can be installed with pip:
pip install py_universalize
Alternatively, you can grab the latest source code from GitHub:
$ git clone https://github.com/shriyashwarghade/py_universalize
$ cd py_universalize
$ pip install .
import universalize
Setup can be done 2 ways
Passing configuration as an parameter.
universalize.setup({
"primary": {
"code": "en",
"file": "en.json",
"display_name": "English"
},
"languages": [
{
"code": "fr",
"file": "fr.json",
"display_name": "French"
}
]
}
)
Passing configuration as an Json file path.
universalize.setup('setup.json')
// setup.json
{ "primary": { "code": "en", "file": "en.json", "display_name": "English" }, "languages": [ { "code": "fr", "file": "fr.json", "display_name": "French" } ] }
Each language block has 3 keys.
code
: Language code,
file
: Language translation json file location
display_name
: Language display name
Once you've completed the setup, you can use locale function with the value by using the dot notation, ex: HOME.HELLO
.
The translate parser understands nested JSON objects. This means that you can have a translation that looks like this:
// fr.json
{
"HOME": {
"HELLO": "Hola"
}
}
universalize.locale('HOME.HELLO','fr')
locale
function accepts two parameters
text
: Dot notated string
language_code
: Translate text
to the given language code. This is an optional parameter. If not given text
will be translated to primary language.
universalize.set_primary_language('en')
Returns an array of currently available languages
universalize.get_languages()
MIT
FAQs
The internationalization (i18n) library for Python.
We found that py-universalize demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.