Skip to content

mberatsanli/multilangPY

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

multilangPY

Import the library

from multilang import multilang

Using

> How to starting

mlang = multilang()

> Set Languages Directory

mlang.set("dir", "../demo/langs/")

> whatIs function

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

> List the language in the defined direcory

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 :)

> How to create the language file (json)

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"
}

> How to get the text or word

mlang.get(CALLED NAME)

Dynamic Example

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

Example Using

# 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

Releases

No releases published

Packages

No packages published

Languages