Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: i18n internationalization functionality in thinbasic / thinair

  1. #11

    Question

    Hi,

    first, SetSearchKey still does not work in the script, has it work for you ?
    i18n.zip

    then, I though a bit about the source code extraction (user's easiness in mind):
    an idea of logic:
    1/ define the default reference language that will be used within the script ex: "en-GB"
    2/ set the language to be displayed ex: "fr-FR"
    3/ localizable text is surrounded by a mere function ex: i18n("My name is {1}",(param1))
    4/ the function process the string as in the attached script v3

    When programming, it is not wanted to have to edit the translation file at the same time, so default text must be in the script (and as a fallback too).

    For extraction:
    1/Retrieve xml filename used in the code, make a backup (filename-[date:hour].xml) or create one if needed.
    2/add attribute "editing" to all sentence elements in the xml file
    3/Get a string after i18n(
    4/Get any comment right above the i18n ('[i] <here comment for translator>)
    5/XMLEscape the comment, the string to build the attribute, and the string to put the text; consideration for use of CDATA
    6/In the xml file, check for existence of the built attribute for the elements containing the reference language attribute.
    7/If not exist: add it
    8/If exist: remove "editing" attribute for that element
    9/Check if wanted translations placeholders exists, add it if needed. Remove corresponding "editing" attribute.
    10/Add or replace comment for translator
    11/Back to step 3 unless no more string to process
    12/Remove elements with "editing" attribute
    13/Sort XML file


    finally, in the last xml file, though I think ]not, I ask: are xml's attributes retrievable through AppConfig ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  2. #12
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Replies

    first: yes it it. Example from your "Original suggestion by EO" folder is working fine

    then: give me some time to study

    finally: at the moment not. It is not a matter to read attributes but how to transform them into the hash table I use inside cAppConfig object.
    XML nodes tree is transformed into a sequence of keys separated by "\"
    So nodes like
    <en-GB>
    <Good_Morning>
    are transformed into the key "en-GB\Good_Morning"
    How to transform attributes?

    I think the best way is to create a dedicated module so we can define a precise XML format to adhere to.
    In that way I can create specific module class dedicated to internationalization that as many hash table as the languages defined in the xml file.
    The <object>.setLocale will set the language intenally setting the active hash table to get keys from.
    Or something like that.

    ...
    thinking ...
    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

  3. #13
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hope to be able to publish a new module to be used as a starting point for more detailed discussions.
    So we can see if I'm on the right track.
    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

  4. #14
    Quote Originally Posted by ErosOlmi View Post
    first: yes it it. Example from your "Original suggestion by EO" folder is working fine
    I can't see why, same version 1.10.5.0 of thinBasic ?
    Here the error file...AppConfig_Locale.tbasic.LastRunTimeError.ini.zip

    Quote Originally Posted by ErosOlmi View Post
    finally: at the moment not. [...]
    I think the best way is to create a dedicated module so we can define a precise XML format to adhere to.
    I apprehend, if you make it a module, will the source code be still available ? I'm not sure how you work with sdk with community.


    Quote Originally Posted by ErosOlmi View Post
    In that way I can create specific module class dedicated to internationalization that as many hash table as the languages defined in the xml file.
    why not have a module per usage:
    a xml module that deal with xml, ((un-)escaping, entities, tags and attributes)
    a i18n module that uses the xml module and that deal with translation

    Quote Originally Posted by ErosOlmi View Post
    The <object>.setLocale will set the language intenally setting the active hash table to get keys from.
    Or something like that.

    ...
    thinking ...
    You'll have to manage multiple language at once when auto-building from code. This is my second argue for 2 modules rather than one.

    Quote Originally Posted by ErosOlmi View Post
    It is not a matter to read attributes but how to transform them into the hash table I use inside cAppConfig object.
    XML nodes tree is transformed into a sequence of keys separated by "\"
    So nodes like
    <en-GB>
    <Good_Morning>
    are transformed into the key "en-GB\Good_Morning"
    How to transform attributes?
    To my understanding, you transformed a tree structure (xml) to a table.
    Attributes looks to me like an array of values stored in the key
    idea: linked lists ? Though I'm not sure how it works (have not studied it yet)
    Last edited by DirectuX; 02-11-2018 at 16:41.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  5. #15
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Ops, SetSerchKey is not yet published, it is in 1.10.6 which I'm working on:
    https://www.thinbasic.com/public/pro...n_1_10_6_0.htm

    I will see if I can publish a preview by this evening so you can test.

    For parsing XML there is an include (B_XML60.INC) and a DLL that wrap standard Microsoft api. But is general purpose and quite complex.
    See examples in \thinBasic\SampleScripts\XML
    I do not want that complexity that's why I developed "AppConfig" module that with few lines of code does what hundred of lines do if using classic xml parsing.
    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

  6. #16
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    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

  7. #17
    Quote Originally Posted by ErosOlmi View Post
    the script works.
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  8. #18
    Quote Originally Posted by ErosOlmi View Post
    I do not want that complexity that's why I developed "AppConfig" module
    I understand, I proposed attributes because they are less restrictive on allowed characters.
    Did you looked at Locale2.xml ?
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

  9. #19
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Quote Originally Posted by DirectuX View Post
    I understand, I proposed attributes because they are less restrictive on allowed characters.
    Did you looked at Locale2.xml ?
    Yes I saw.
    I'm creating a new module based on that example.

    As soon as I will have something working I will publish, maybe by tomorrow if family permits
    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

  10. #20
    Quote Originally Posted by ErosOlmi View Post
    maybe by tomorrow if family permits
    totally agree
    ThinBasic 1.11.6.0 ALPHA - Windows 8.1 x64

Page 2 of 3 FirstFirst 123 LastLast

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
  •