Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: i18n internationalization functionality in thinbasic / thinair

  1. #21
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Inside
    <Sentence text="Good_Morning" lang="en-GB" >Good Morning</Sentence>
    can we assume that
    "Good_Morning" text
    is unique over a language, whatever node it is present?
    In this way I can have an internal hash table key\data where key can be LANG + \ + TEXT like "en-GB\Good_Morning"
    Setting the Locale would set the main part of the key

    I mean I'm trying to find a way to define something like to below example.
    It would be possible to have up to 3 levels of nodes but such nodes are only a way to keep translations organized and not part of the key to search for.
    Otherwise things like i18n("Good_Morning") would not be possible.



    
    
    
    <?xml version="1.0" encoding="utf-8"?>
    <i18n>
    
    
    	<Main_Script>
    		<Globals>
    			<Sentence text="Good_Morning" lang="en-GB" >Good Morning</Sentence>
    			<Sentence text="Good_Morning" lang="fr-FR" >Bonjour</Sentence>
    			<Sentence text="What_Is_Your_Name" lang="en-GB" >What is your name?</Sentence>
    			<Sentence text="What_Is_Your_Name" lang="fr-FR" >Quel est votre nom?</Sentence>
    		</Globals>
    		<!-- <some comment to translators> -->
    		<Sentence text="{1}_Is_My_Name" lang="en-GB" >{1} is my name.</Sentence>
    		<Sentence text="{1}_Is_My_Name" lang="fr-FR" >Je m'appelle {1}.</Sentence>
    	</Main_Script>
    	
    	<Include_myIncludedFile>
    		<Dialogs>
    			<Sentence text="Dialog_Title" lang="en-GB" >Dialog title</Sentence>
    			<Sentence text="Dialog_Title" lang="en-GB" >Titre de la fenêtre</Sentence>
    		</Dialogs>
    		<Menu>
    			<Sentence text="Close_all_files" lang="fr-FR" >Close all files.</Sentence>
    			<Sentence text="Close_all_files" lang="fr-FR" >Fermer tous les fichiers.</Sentence>
    		</Menu>
    	</Include_myIncludedFile>
    	
    </i18n>
    




    Also trying to figure out how to interact between the editor, thinAir, and translations in order to find a way thinAir is aware of the need of some translations.
    Also to have the possibility to automatically create translations

    Will read back all previous suggestions

    Thinking ...
    Any idea is welcome.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #22
    Quote Originally Posted by ErosOlmi View Post
    Will read back all previous suggestions
    Yep' , as some questions were already discussed.

    Quote Originally Posted by ErosOlmi View Post
    Otherwise things like i18n("Good_Morning") would not be possible.
    (as in previous suggestions) Maybe not i18n("Good_Morning") but i18n("Good morning") as in plain english.
    then, the xml building script convert the string to a unique escaped tag (lang/text) and this is transparent to the programmer and less human-error prone and provides a fallback.

    Quote Originally Posted by ErosOlmi View Post
    can we assume that
    "Good_Morning" text
    is unique over a language, whatever node it is present?
    I think so, and the xml automated building can insure this is the case.

    Quote Originally Posted by ErosOlmi View Post
    Thinking ...
    Any idea is welcome.
    I wish to know if we go with <tags> and "attributes" or only <tags> ? I'm not sure to understand what you decided so far.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  3. #23
    considering my last question just above, if you choose the <tag> only version , xml might look like this:

    HTML Code:
    <?xml version="1.0" encoding="utf-8"?>
    <i18n>
    	<Main_Script>
    		<Globals>
    			<Good_Morning>
    				<en-GB>Good Morning</en-GB>
    				<fr-FR>Bonjour</fr-FR>
    			</Good_Morning>
    			<What_Is_Your_Name>
    				<en-GB>What is your name?</en-GB>
    				<fr-FR>Quel est votre nom?</fr-FR>
    			</What_Is_Your_Name>
    		</Globals>
    		<!-- <some comment to translators> -->
    		<#1#_Is_My_Name>
    			<en-GB>{1} is my name.</en-GB>
    			<fr-FR>Je m'appelle {1}.</fr-FR>
    		</#1#_Is_My_Name>
    	</Main_Script>
    	<Include_myIncludedFile>
    		<Dialogs>
    			<Dialog_Title>
    				<en-GB>Dialog title</en-GB>
    				<fr-FR>Titre de la fenêtre</fr-FR>
    			</Dialog_Title>
    		</Dialogs>
    		<Menu>
    			<Close_all_files>
    				<en-GB>Close all files.</en-GB>
    				<fr-FR>Fermer tous les fichiers.</fr-FR>
    			</Close_all_files>
    		</Menu>
    	</Include_myIncludedFile>
    </i18n>		
    or if we keep a symmetry list between xml's tags and the string passed to i18n it could even be simplier:

    ' Symmetry list
    ' syntax : [tag] [i18n submitted string] 
    ' * tag could be zero padded to keep alignment
    '
    1 "Good Morning"
    2 "What is your name?"
    3 "{1} is my name."
    4 "Dialog title"
    5 "Close all files."
    
    HTML Code:
    <?xml version="1.0" encoding="utf-8"?>
    <i18n>
    	<Main_Script>
    		<Globals>
    			<1>
    				<en-GB>Good Morning</en-GB>
    				<fr-FR>Bonjour</fr-FR>
    			</1>
    			<2>
    				<en-GB>What is your name?</en-GB>
    				<fr-FR>Quel est votre nom?</fr-FR>
    			</2>
    		</Globals>
    		<!-- <some comment to translators> -->
    		<3>
    			<en-GB>{1} is my name.</en-GB>
    			<fr-FR>Je m'appelle {1}.</fr-FR>
    		</3>
    	</Main_Script>
    	<Include_myIncludedFile>
    		<Dialogs>
    			<4>
    				<en-GB>Dialog title</en-GB>
    				<fr-FR>Titre de la fenêtre</fr-FR>
    			</4>
    		</Dialogs>
    		<Menu>
    			<5>
    				<en-GB>Close all files.</en-GB>
    				<fr-FR>Fermer tous les fichiers.</fr-FR>
    			</5>
    		</Menu>
    	</Include_myIncludedFile>
    </i18n>


    XML files attached : v3.zip
    memo:the built xml can be written to be human readable and contain script-unused informations.
    Last edited by DirectuX; 03-11-2018 at 10:22. Reason: explanation rewrite for clarity
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  4. #24
    Quote Originally Posted by DirectuX View Post

    or if we keep a symmetry list between xml's tags and the string passed to i18n it could even be simplier:

    ' Symmetry list
    ' syntax : [tag] [i18n submitted string] 
    ' * tag could be zero padded to keep alignment
    '
    1 "Good Morning"
    2 "What is your name?"
    3 "{1} is my name."
    4 "Dialog title"
    5 "Close all files."
    
    as a reminder (mostly for myself) I found that the INI module can manage that.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Page 3 of 3 FirstFirst 123

Similar Threads

  1. MLGrid: new sheets functionality
    By ErosOlmi in forum UI (User Interface)
    Replies: 0
    Last Post: 06-09-2011, 11:30
  2. How would you implement an Undo functionality in an app?
    By Michael Hartlef in forum General
    Replies: 8
    Last Post: 20-08-2010, 19:03
  3. Print functionality
    By ErosOlmi in forum thinAir General
    Replies: 0
    Last Post: 17-10-2005, 16:55

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •