Giter VIP home page Giter VIP logo

Comments (41)

thomthom avatar thomthom commented on May 25, 2024

Sounds good.

(Without the globals, of course ;) )

from sketchup-stl.

jimfoltz avatar jimfoltz commented on May 25, 2024

I was wondering about this. Currently, any .strings files need to go in the Resources folder for langhandler.rb (via Sketchup.get_resource_path) to find them. Does the built-in .rbz installer support installing to the Resource folder? Will langhandler.rb need to be modified to look in an extension's folder for the .strings file?

In short, how are .strings files going to be handled in an extension like sketchup-stl?

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

Dan suggested the possibility to pass a full path (of the strings file) to LanguageHandler.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

If that doesn't work we can use the translator class I use from my TT_lib2: http://www.thomthom.net/software/sketchup/tt_lib2/doc/TT/Babelfish.html

from sketchup-stl.

scottlininger avatar scottlininger commented on May 25, 2024

RBZ can only install to the Plugins folder at the moment.

We could modify the base langhandler.rb functionality to accept a full path. Perhaps we could prototype it inside this project, then I could take our changes back to the larger SketchUp team to see about getting it rolled into the default SketchUp client install.

Or if we agree that it would be better to figure out a standard for allowing RBZ to install into Resources, we could explore that too.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Subclass the langhandler?

LanguageHandler.ParseLangFile is the culprit. Though, it looks like one need to copy the entire method into the subclass - even though it's just the first line that needs changing.

(Btw, why is the method names in LanguageHandler constants? (upper capital) )

from sketchup-stl.

scottlininger avatar scottlininger commented on May 25, 2024

LanguageHandler was written years and years ago, before there were Ruby naming conventions on the team. Thus the weird capitalization.

Subclassing seems reasonable to me.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

I think I've found an easy way to sub-class LangHandler to correct the path issue without rewriting any of the code.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

@jimfoltz , are you able to merge your changes into upstream? I don't want to implement localisation with pending changes to be merged as I'll be creating global changes.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Cursed! My little shim didn't work when applied to a sub-class. I think I might just rewrite it from scratch.

from sketchup-stl.

jimfoltz avatar jimfoltz commented on May 25, 2024

I think I've found an easy way to sub-class LangHandler to correct the path issue without rewriting any of the code.

Maybe a rewrite under the CommunityExtensions scope would be better? It isn't as if there is a lot to rewrite, or a huge savings to be had by sub-classing.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

I'm currently working on a draft rewrite which cleans up a lot, extends, but provide backwards compatibility with LangHandler.

from sketchup-stl.

jimfoltz avatar jimfoltz commented on May 25, 2024

@jimfoltz , are you able to merge your changes into upstream? I don't want to implement localisation with pending changes to be merged as I'll be creating global changes.

Don't wait on me... I don't have a pull request pending and my changes can be reworked easily enough.

git is supposed to be the solution to to these types of development problems. Makes me think we are still not using it optimally.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

I just thought it could perhaps save some manual merges.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

I've implemented localisation: https://github.com/thomthom/sketchup-stl/tree/feature-translator

I wrote a new parse for the string files - it can read the files that LangHandler does, and have aliases that matches the LanguageHandler class so it can be used as a drop in replacement in other projects. I has some extended capabilities as well that should make it easier to read and format the .strings files.

I need to implement localisation of the webdialog before I can push the change.

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

The parser looks very good! Are you going to do the webdialog localisation in extra files (js), or embed it in the Translator class? (like ae_TextureResizer/Translate.rb: Translate.webdialog(dlg))

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

I'll be cleaning up the parse with better comments so it's easier to work out each step in it. I found it very easy to extend. I implemented the string concat feature in a couple of minutes.

The WebDialog localisation is done by sending a JSON with replacement strings (jQuery selectors as keys) to the webdialog where it performs the replacement. It's done when the DOM is ready so it should be immediate. I use similar technique in Vertex Tools and it's worked well so far. (Though I might need to make adjustments if the JSON becomes too large to transfer - but atm it's nowhere near to be an issue.)

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Implemented WebDialog translation! :D (Nice to get something done while you wait for a render to complete...)

It'd be nice to be able to see it working in a localized version of SketchUp though...
Andreas, do you run a German SketchUp?

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

Yes (translating...)

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Excellent!

@scottlininger is there an easy way to test localisation? Swap locale in SketchUp?

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

Ha, we have been waiting long for that! I don't know of such an option in SU (or any environment variables that SU would listen to), and even if you intentionally install a foreign language version it will fallback to English on your computer.
Someone in the Help Forum found out that you have to change the operating system locale: https://productforums.google.com/d/msg/sketchup/xsfnZtkWxnQ/0kbVoio235gJ
(The locale can be changed also with a single language license of Windows.)

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Think there is a thread in the Beta forum - but appeared to be for OSX. Wonder if it was possible to install two versions side by side...

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

You can install side by side (and then switch symlinks or rename it). But if it detects your system locale is not Chinese, then it falls back to English even if you intentionally wanted to use/test the Chinese version. So any version will show up English except the single one that matches your locale.

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

One issue is: I first set the folder name to de-DE, but Translator finds it only if it is de (what SketchUp returns as locale). Maybe we could make a fallback.
SketchUp itself also does not have a fallback, so pt-PT users get English because their locale is not exactly pt-BR.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Yea - it currently matches what LanguageHandler does. So one need to follow the folder naming convention you see in SketchUp's resource folder.

How would the fall-back work? There is no way to get the system locale - just the SketchUp locale. And doesn't SketchUp return a locale code only if it's translated into that locale?

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

When I edit the .strings file in Notepad++ I set the highligher to use C syntax which works well except for the multi.-line strings. Haven't found another language syntax that matches that.

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

The locale is recognized and the translations all display correctly.

Fixed invalid file in Translator: 10a90fa
German translation: 89c8fca
Some layout adjustments might be necessary. The issue with absolute px positioning is that it sometimes words don't fit (in this case some letters of 'Einheiten' were covered behind the select box). 01547ce

As for a fall back for similar locales, maybe we can do soething with regular expressions and Dir.glob()
I found a code snippet:

language = locale[/^[^\-]+/]
available_files = Dir.entries(stringsdir).find_all{|f|
  File.basename(f)[/^#{locale}/i]
}.concat(Dir.entries(dir).find_all{|f|
  File.basename(f)[/^#{language}/i]
})
return if available_files.empty?
path = File.join(stringsdir, available_files.first)

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Nice. Can you send me a pull request so I can merge your changes into my branch?

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

About the fallback - what is it doing?

As I mentioned before, does SketchUp report the locale of anything other than the locales that SketchUp is available in? In which case such fallback would have no effect.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

https://developers.google.com/sketchup/docs/ourdoc/sketchup#get_locale

Sketchup.get_locale
The get_locale method returns the language code for the language SketchUp is running in.

Valid return values include: en-US, fr, it, de, es, ja, ko, zh-CN, zh-TW, pt-BR, nl, ru.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Not sure if that list is up to date... @scottlininger ?

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Nice. Can you send me a pull request so I can merge your changes into my branch?

Never mind - I found I could do the pull request myself. :)

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Should add support for possible Unicode BOM. UTF-8 should be enough, right?

from sketchup-stl.

tylermiller avatar tylermiller commented on May 25, 2024

Hey guys - was just catching up on the dialog and saw the question about
forcing SU to run in a particular language. On Windows, there is a
commandline switch you can use:

sketchup.exe /lang es

where es is the language code (Spanish in this example).

One caveat - There must be the corresponding language folder under the
/Resources sub-folder. One dirty trick I use is to just copy the english
folder into a language that I want to test, then just change the strings
file for the particular plugin I'm using.

Hope that helps,
Tyler

On Wed, Nov 28, 2012 at 8:17 AM, Thomas Thomassen
[email protected]:

Should add support for possible Unicode BOM. UTF-8 should be enough, right?

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-10806099.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

That's great Tyler! Thanks for the heads up!

@Aerilius - can you zip and send me the German resource folder? I'd like to try this.

from sketchup-stl.

Aerilius avatar Aerilius commented on May 25, 2024

It works!
@tyler: Thanks!! We have urged the support guys on this question so much, but they cannot keep up with your magic! Though command line parameters aren't officially supported, can we use them to solve language problems in the forum?

@thomthom: I'll send you some languages. Some time ago I got errors when mixing language files, maybe when code pages didn't match.

from sketchup-stl.

tylermiller avatar tylermiller commented on May 25, 2024

Aerilius -

Feel free to discuss the /lang switch on the forums. If it is useful for
our developer partners, I'm all for sharing it.

-Tyler

On Wed, Nov 28, 2012 at 4:10 PM, Aerilius [email protected] wrote:

It works!
@tyler https://github.com/Tyler: Thanks!! We have urged the support
guys on this question so much, but they cannot keep up with your magic!
Though command line parameters aren't officially supported, can we use them
to solve language problems in the forum?

@thomthom https://github.com/thomthom: I'll send you some languages.
Some time ago I got errors when mixing language files, maybe when code
pages didn't match.

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/45#issuecomment-10827495.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

@tyler: This is working great! πŸ‘ πŸ‘
It would be nice if there was a download for developers so they (we) could download all the language packs in one package for testing.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Realized I'd previously asked for how Sketchup.get_localeworked - the reply was:

the method works in the following way, if the default OS language is different than English the method checks the resource folder in the SU install and see if the default OS language has a correspondent resource file, in which case the OS language is returned, otherwise the default en-US is returned.

from sketchup-stl.

tyler avatar tyler commented on May 25, 2024

Hey guys. You ought to know that when you use @-name it notifies the person with that GitHub username. To get your intended effect, you'd want to use "@tylermiller". As it is, I keep getting emails from this thread.

from sketchup-stl.

thomthom avatar thomthom commented on May 25, 2024

Ah! Gotcha! πŸ‘ Sorry!

from sketchup-stl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.