from multilang import multilang
mlang = multilang()
mlang.set("dir", "../demo/langs/")
mlang.whatIs(value, print4me=False)
value | what is does | ouput |
---|---|---|
lang or language | Prints the selected language | return |
dir or directory | Prints the selected directory | return |
mlang.languages(print4me=False, helper=False)
paramters | what is does | output |
---|---|---|
print4me | Print for you language file(s) in directory | array |
helper | writes in detail the file(s) in directory. You just using with print4me. | just try :) |
For example, the folder with the language files: ../multilang/languages/
and we create a language folder in the directory. Create LANGUAGE.json
for example ru.json
and az.json
"CALL_NAME": "TEXT or WORD"
// ru.json
{
"merhaba": "Привет",
"merhaba_kullanici": "Привет %s"
}
// az.json
{
"merhaba": "Salamlar",
"merhaba_kullanici": "Salam %s"
}
mlang.get(CALLED NAME)
You can use different languages within a project.
from multilang import multilang
mlang = multilang()
mlang.set("lang", "tr")
print(mlang.get("merhaba_kullanici") % "Melih")
mlang.set("lang", "az")
print(mlang.get("merhaba_kullanici") % "canim ben")
Output;
> Merhaba Melih
> Salam canim ben
# main.py
import multilang
mlang = multilang.multilang()
mlang.set("dir", "app/langs/") # Set the new directory
mlang.set("lang", "az") # Set az lang
mlang.get("merhaba") # Output (return): Salamlar
print(mlang.get("merhaba_kullanici") % "Melih") # Output (print): Salam Melih