Jump to content

dany
 Share

Recommended Posts

AU3Text.au3 v1.0

An extensive UDF to ease the internationalization of AutoIt scripts and programs. Add multi-lingual support to your scripts and programs in a consistent and portable manner.

Main features:

  • Store messages in a human-readable INI format.
  • Organize messages in different categories.
  • Handle singular and plural string variants at run time.
  • Expands meta-characters and all AutoIt macro's.
  • Supports UTF-16 Little-Endian encoding.
  • GUI Menu and Combo Create/Read helper functions.
  • Command line utility to extract messages from AutoIt scripts.
  • Fully portable!
The download contains the following files:
ReadMe.txt                  Instructions and information on the UDF.
AU3Text-HowTo.txt           Step by step instructions to convert programs for
                            internationalization with AutoIt.
AU3Text-Demo.au3            AU3Text demo.
AU3Text-Extractor.au3       Source file for command line utility to extract
                            AU3Text messages from scripts. You'll need to compile
                            this script before you can use it. This is BETA software!
LibAU3Text.au3             Main AU3Text library.
LibAU3TextGUI.au3          AU3Text GUI helpers.
LibAU3TextDev.au3          Additional developer functions.
LibLocale.au3              Locale functions. Originally based on guinness'
                            excellent _GetOSLanguage function, but has grown into
                            a full stand-alone UDF.
LibIni.au3                 UTF-16 LE INI functions.
LibStringFormatEx.au3      Modified StringFormat function. See
                            http://www.autoitscript.com/forum/topic/139260-autoit-snippets/page__st__60#entry1010824
I18nAU3Text-Demo.en.lng    English demo language file.
I18nAU3Text-Demo.nl.lng    Dutch demo language file.
I18nAU3Text-Translation-HowTo.txt
                            Basic translation instructions.
ResAU3Text-Extractor.ico   Pic unrelated :)

A simple example of translating a string:

#include 'LibAU3Text.au3'
_AU3Text_BindTextSection('MESSAGES', 'nl') ; Set translations to dutch.
; ... Create a GUI.
; Translate a string:
GUICtrlCreateLabel(_AU3Text('The flying dutchman flies again.', 'FLYING_DUTCHMAN'), -1, -1) ; De vliegende hollander vliegt alweer.
; Translate a string with plural variants:
GUICtrlCreateLabel(StringFormat(_AU3Text_Plural('Deleted %i file.', 2, 'DELETED_FILES'), 2), -1, -1) ; 2 bestanden verwijdert.
; Using shorthand functions:
GUICtrlCreateLabel(_('The flying dutchman flies again.', 'FLYING_DUTCHMAN'), -1, -1)
GUICtrlCreateLabel(StringFormat(_P('Deleted %i file.', 2, 'DELETED_FILES'), 2), -1, -1)
; Let AU3Text generate the INI keys, keys are MD5 hashes of the messages.
GUICtrlCreateLabel(_('The flying dutchman flies again.'), -1, -1)
GUICtrlCreateLabel(StringFormat(_P('Deleted %i file.', 2), 2), -1, -1)
; ...

The UDF:

AU3Text.zip

If you encounter any bugs or have any suggestions, requests or improvements, then please let me know.

Happy coding!

edit 1: zip added

edit 2: If you compiled AU3Text-Extractor and want to test it, run it against AU3Text-Demo like this:

AU3Text-Extractor.exe Au3Text-Demo.au3 be

This will create AU3Text-Demo.be.lng in the I18n directory.

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

well quite a coincidence , iv just been asked if i can translate my speed tester app into French http://www.gmwsoftware.co.uk/guestbook.html

I was wondering how i might go about doing this as of course if i do it for French i really should do many of the other languages that use my software.

All i need to do now is hope i can figure out how your great looking AU3text works :-/

cool timing coincidence,

Many Many thx.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

All i need to do now is hope i can figure out how your great looking AU3text works

Thanks for the compliment :) Just take a good look at the demo script. You'll figure it out, it isn't hard to set up. Post any questions or problems here if you have them!

edit: Included a How-To in the zip with instructions on how to prepare programs for internationalization with AutoIt.

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

Look at

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Very impressive MrCreator. Mine is just a specialized little tool and I'm not planning on developing a GUI until I have a stable and bulletproof version 1 command line tool.

I'm looking through the code and it's very interesting. Yours is definitely a different approach from mine.

I ran ATT on AU3Text-Demo.au3. It found way too many strings but I can just use the regexp from AU3Text-Extractor to pick up the ones I want. That's pretty awesome. However, it didn't pick up the strings spread across multiple lines. I'll have to figure out a regex pattern for that. And I certainly didn't expect it to rewrite my script! He, lucky for me the script was open in notepad++ so I could undo it all.

Well, it's going to keep me busy for the next hour or so I bet. I'll post further comments in your thread. But I'll say it again, very impressive.

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

@dany

Thx for the PM, i had been reading your edits though. The help is appreciated :)

It looks like i made a major incorrect assumption in that i was hoping for something that would not just organize the language files and help implement them but i was looking for something that would actually do the translation to !

However after looking and gaining some understanding of how you have gone about using individual language files it did open my eyes as to how to go about the whole situation.

I have decided in the end that rather than use other peoples UDF's i would prefer to just keep it as simple as possible and also under my complete control (without parts that i just dont understand).

So what im going to do is replace all my text strings with a func ie _trans("text to translate") (which i would have to do anyhow).

Then when a $makeEnglishFile=1 var is set the _tras func would just create an English translation file.

So after changing all my strings in my code and setting the $makeEnglishFile=1 i would run my program and end up with an English language file. Iv decided on a very simple layout :-

some text,some text

Hello,Hello

More text,More text

text to translate,text to translate

etc etc.

then im thinking i can create a separate AI code to run through the English file and translate the whole thing for each language i need:-

some text,un texte

Hello,Bonjour

More text,Plus de texte

text to translate,texte à traduire

Now atm im using google translate desktop to do the actual translating, its a very simple gui that i can get AI to automate paste English in and retrieve whatever language i need out.

What would be really handy is an AI UDF that i could use really easily {ie. $TransOut=_translate_func("text to translate",lang) } to translate but iv not seen anything quite as simple as that, but im quite happy getting a 3rd party app to do it, id only need to use it once(ish) for each language.

So the final part of the procedure is after creating the individual language files i can turn off the $makeEnglishFile=0 and then on running my app it would read the correct language file into an array and it would then be easy for the _trans("text to translate") func to cross-ref the parsed in English string against the language array.

Well thats what im going to try anyhow. Im sure you chaps have already created all id really need but as i say reading and understanding other people code & how to use it can be a bit out of my league :-/ but i do really appreciate the methodology ,not sure id have thought of it any time soon , lol.

Cheers,

JD.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Nice idea. One point to make (having skimmed through the code) you don't need to declare $i in _GetOSLanguage for example. I also don't know if others had this problem but I used Tidy (Ctrl+T in SciTE) on your code as it was highlighting as one massive comment, due to alignment issues.

I also couldn't run the example due to the Au3 Script being encoded as 'UTF8 with BOM'.

Func _GetOSLanguage()
    ; Local $i
    For $i = 1 To $__Locale_aTable[0][0]
        If StringInStr($__Locale_aTable[$i][0], @OSLang) Then
            Return $__Locale_aTable[$i][3]
        EndIf
    Next
    Return SetError(1, $E_LOCALE_UNKNOWN_LANGUAGE, $__Locale_aTable[1][3])
EndFunc

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

But the demo did work in my case though .

Because you re-saved it. I fixed it at my end, but it's best issues like this get resolved now rather than 2 years down the line.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Nice idea. One point to make (having skimmed through the code) you don't need to declare $i in _GetOSLanguage for example. I also don't know if others had this problem but I used Tidy (Ctrl+T in SciTE) on your code as it was highlighting as one massive comment, due to alignment issues.

I also couldn't run the example due to the Au3 Script being encoded as 'UTF8 with BOM'.

Ah yes, I'm in the habit of declaring all variables because that's best practise in PHP. But is this an AutoIt issue or something to do with the wrappers and Tidy? Either way, I'll do some code cleaning.

Also, what IS the best format to save my scripts then? I couldn't reproduce your error so I'm curious as to why that would happen...

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

Based on guinness' comment I've updated the zip:

  • Removed all declarations of Local $i and let autoit handle scoping etc.
  • Removed a few other stray unused variables I came across.
  • Changed the encoding of all files to UTF-16 LE. That should be best.
  • Lastly, fixed a small bug in both _AU3Text_Plural and _AU3Text_SectionPlural, now plural forms should be picked up correctly.

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

[*]Removed all declarations of Local $i and let autoit handle scoping etc.

If only used in a For loop then there is no need to declare it.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

That's the only place I use $i, $ii etc. i as in incrementer. Admittedly not very descriptive but since it's the only place I use one-letter variables always easy to spot.

Edited by dany

[center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF

Link to comment
Share on other sites

  • 7 years later...

@dany Thanks for the UDF, it looks very promising, sadly it is no longer working with the latest version of AutoIt. I am not going to necro-post this thread, but I am indeed here to resurrect it!

I fixed up the UDF to run with the latest version, as well as converted the encoding of the script files to UTF-8 :D

Here is the file: AU3Text (Fixed - UTF16 NoBOM - AutoIt v3.3.14.5).zip

Spoiler

AU3Text (Fixed - UTF8 - AutoIt v3.3.14.5).zip
This is the older version which uses UTF8 everywhere, I had issues with the extractor.

Edit: Fixed some more stuff.

Edit 2: Fixed yet more stuff, reverted some of the code to use UTF16 w/o BOM because Ini functions require that encoding...

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...