International language in Linux
International language in Linux
How to enable international language in Linux using .mo files?
Re: International language in Linux
If the 'mo' file extension you are describing, has a functionnal link with this (source : https://file.org/ ), it seems that this type of file is used by Audacity. In this way, libraries are downloadable here. Note that you can access to the source codes and their authors in the official site.
Re: International language in Linux
Re: International language in Linux
My apologize...
In this way, maybe you can find a library in the available packs here, and also contact the authors...
https://poedit.net/download
In this way, maybe you can find a library in the available packs here, and also contact the authors...
https://poedit.net/download
Re: International language in Linux
Olli
1. I know how to use poedit
2. I can compile the .mo binary
problem:
I need an engine or module or procedure that can pull lines from a .mo file and insert into a program interface.
For example, you have French. The program itself will pull the strings from the French localization file. The program interface will be in French.
I do not think that the authors of poedit will write a module for PureBasic. poedit is just a program to create a localization file
The Format of PO Files
I can make my own file format, just a list of strings. But there is the problem of determining the language of the system. That is, I will have to solve this issue. Maybe there is a ready-made solution and I will get rid of 2 problems at once.
1. I know how to use poedit
2. I can compile the .mo binary
problem:
I need an engine or module or procedure that can pull lines from a .mo file and insert into a program interface.
For example, you have French. The program itself will pull the strings from the French localization file. The program interface will be in French.
I do not think that the authors of poedit will write a module for PureBasic. poedit is just a program to create a localization file
The Format of PO Files
I can make my own file format, just a list of strings. But there is the problem of determining the language of the system. That is, I will have to solve this issue. Maybe there is a ready-made solution and I will get rid of 2 problems at once.
Re: International language in Linux
Can you not just call gettext (as a c function or commandline program) after installing your mo files in the system? I think the 'library' is already there in linux, you just have to learn which commands to use. But i just used mo files and gettext in php, so I don't know exactly how this works for a binary application. Maybe wiki/Gettext#Running helps.
Re: International language in Linux
Olli
Thanks, I got the OS language
LANGUAGE = ru
and 44 more variables.
#NULL
Thanks, I got the OS language
Code: Select all
If ExamineEnvironmentVariables()
While NextEnvironmentVariable()
Debug EnvironmentVariableName() + " = " + EnvironmentVariableValue()
Wend
EndIf
and 44 more variables.
#NULL
Code: Select all
ImportC "???"
...
EndImport
Re: International language in Linux
It seems the functions are already available like gettext_() for example, but I don't know how to use them.AZJIO wrote: #NULLCode: Select all
ImportC "???" ... EndImport
But I found this: Translator/Multilanguage with locale support, post by djes.
I had to comment out 3 parts (the line with GetThreadLocale_() and 2 Cases) and it would run on linux and the translation works (after fixing the slash in sample.pb as well).
Re: International language in Linux
Did this:
For universality, it is necessary to allow in the ini-file to specify the path to the localization file, since there may be a problem in the language definition.
Code: Select all
EnableExplicit
; Determination of the interface language and apply
Global UserIntLang, UserIntLang$, PathLang$, tmp$, i, *Lang
; Defines the OS language
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
If OpenLibrary(0, "kernel32.dll")
*Lang = GetFunction(0, "GetUserDefaultUILanguage")
If *Lang
UserIntLang = CallFunctionFast(*Lang)
EndIf
CloseLibrary(0)
EndIf
CompilerCase #PB_OS_Linux
If ExamineEnvironmentVariables()
While NextEnvironmentVariable()
If Left(EnvironmentVariableName(), 4) = "LANG"
; LANG=ru_RU.UTF-8
; LANGUAGE=ru
UserIntLang$ = Left(EnvironmentVariableValue(), 2)
Break
EndIf
Wend
EndIf
CompilerEndSelect
#CountStrLang = 3 ; number of translation strings and correspondingly array
Global Dim Lng.s(#CountStrLang)
; Interface strings even if the language file is not found
Lng(1) = "Signal"
Lng(2) = "Hours"
Lng(3) = "Minutes"
; ...
; defines the paths to the language file
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
PathLang$ = GetPathPart(ProgramFilename()) + GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + "_Lang.txt"
CompilerCase #PB_OS_Linux
PathLang$ ="/usr/share/locale/" + UserIntLang$ + "/LC_MESSAGES/" + GetFilePart(ProgramFilename(), #PB_FileSystem_NoExtension) + ".txt"
CompilerEndSelect
; If the language file exists, then it uses it
If FileSize(PathLang$) > 1
If ReadFile(0, PathLang$) ; If the file descriptor was opened, then ...
i=0
While Eof(0) = 0 ; Loop until end of file is reached.
tmp$ = ReadString(0) ; reading the line
; If Left(tmp$, 1) = ";"
; Continue
; EndIf
tmp$ = ReplaceString(tmp$ , #CR$ , "") ; correction if in windows
If tmp$ And Left(tmp$, 1) <> ";"
i+1
If i > #CountStrLang ; the Lng() array is already set, but if there are more rows than you need, then we do not allow unnecessary ones
Break
EndIf
Lng(i) = tmp$
Else
Continue
EndIf
Wend
CloseFile(0)
EndIf
; Else
; SaveFile_Buff(PathLang$, ?LangFile, ?LangFileend - ?LangFile)
EndIf
; End => Language Definition