Jump to content


Photo

resourcestrings ... how to use them?


  • Please log in to reply
2 replies to this topic

#1 markus_ja

markus_ja
  • Members
  • 319 posts
  • LocationAustria

Posted 03 March 2016 - 01:29 PM

Hello,

 

how to use resourcestring to create multi-language apps? I know that I can declare a resourcestring variable in SMS, and that resourcestring is included in the html file als array $R. But the strings are included in the html file in the language I defined it in the code.

 

e:g.:

resourcestring
  RS_Save = 'Save';

becomes

var $R = ['Save', ...]

alert($R[0]);

I also saw, that I can export the resourcestrings as json file, but for what reason?

So how can I change the language in my app using resourcestring?

 

 



#2 Christian-W. Budde

Christian-W. Budde
  • Members
  • 334 posts
  • LocationGermany

Posted 03 March 2016 - 01:53 PM

Currently, this feature is not fully implemented. We started support for this (hence the export to JSON), but didn't implement it fully. However, as you already noticed the resource strings are identified by $R, so it's pretty easy to update this variable with data coming from a JSON file by yourself.

Once you have the JSON file (for one language) you can alter its values to any other language. Then, when the application has been loaded you have to load the JSON file for the language of choice as well and replace the current values of $R by this.

If not limited in time today, I could write some example code, but it's straight forward. The only problem with this approach is the fact that if you add more variables you have to adapt your JSON files as well. This might be cumbersome in the long run. So hopefully a little support by the IDE will get implemented sooner or later.

What's high on the list is (Eric's suggestions to this topic):
  • be able to specify gnutgettext dictionaries at the project level
  • be able to populate/update the dictionaries from the resource strings
  • during compilation generate json files with localized strings (using the dictionaries)
  • maybe be able to mark of form as localizable, it would then use resourcestrings in its auto-generated code rather than simple strings
While these plans have been made, there is currently no roadmap for this part.

Personally, I don't use/need localization so far, thus there's no motivation for me to implement it. But I can only speak for myself here and only for now. It might surely change in the future.

#3 markus_ja

markus_ja
  • Members
  • 319 posts
  • LocationAustria

Posted 03 March 2016 - 03:13 PM

Thanks for the quick reply. Currently the main language of my app is german, but it would be great to have an english version in the future. So, I need to decide, how to implement it, in order swtiching language would be easy in the future. If you could address that feature in the next year or so, that would be sufficient for me.

More important to me is the code completion / createn and navigation functionality, as I already posted.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users