Remove resources at runtime

  1. 7 weeks ago

    Jeff T

    Apr 5 Midlands of England, Europe

    In principle, I know that in OSX, an app's resources such as bitmaps and language files are read-only by the app which contains them.

    But is there any way to delete some using a shell command (run as sudo?)
    What I want to do is delete language files (eg the folder de.lproj ) based upon user choice, so that when the app next runs, it appears in the user's chosen language rather than whatever the OS is set to be.
    I can do it using Finder if I supply an admin password, and it doesn't break the code signature, so it must be possible by some route.
    Im just not familiar enough with shell commands to know what to issue..

    We use defaults write {BUNDLE_ID} AppleLanguages '("es")' for instance and it works great.

    {BUNDLE_ID} is taken from the Mac Build Settings

    We use the originally proposed hack(Yuck) on PC.

  2. What if a different user (or the same user) on the computer wants to revert the language (and you removed the support files). I've never done this, but I think you want to be modifying the configuration files; similar to following posts:
    https://forum.xojo.com/57954-forcing-a-locale/
    https://blog.xojo.com/2013/12/17/how-os-x-chooses-a-language/
    https://blog.xojo.com/2014/03/05/picking-a-language-at-runtime/

    I apologize in advanced if you already looked at these, but removing the language files seemed a little extreme. But perhaps I completely misread the intent.

  3. Christian S

    Apr 5 Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Jeff, don‘t do it.
    This will break your app‘s code signature.

  4. Jeff T

    Apr 5 Midlands of England, Europe

    Jeff, don‘t do it.
    This will break your app‘s code signature.

    You would expect so, but It doesn't seem to do that, and I have talked people through this manually.

    how-os-x-chooses-a-language/

    Nope. I have people whose locale should be French but want the app to run in English. Changing the whole system is not viable, even temporarily.

    To do this you could write your own localization system using a database or other resource based files,

    I know. And I have considered it. But after trying this approach on even one window, I decided I am not going to go through the whole app and create a system that programatically changes all the menu items based on a database.

    Really, we could use a runtime app property that makes this happen.
    After all, when a window is displayed /created, the app is getting the string resources after querying the OS locale.
    All we need is something that says 'ignore what you found, use this language instead'

    Right now, I know that just deleting the fr.lproj folder achieves exactly what I need, making a French system run in English.

  5. Christian S

    Apr 5 Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    There is a system preferences where you can pick language per app.

  6. Jeff T

    Apr 5 Midlands of England, Europe

    There is a system preferences where you can pick language per app.

    Thats new.. Catalina only.. Thanks for that.
    I think about 30% of my customers have mentioned Catalina so far

  7. Jeremie L

    Apr 5 Testers, Xojo Pro, XDC Speakers, MVP Europe (France) - packr.app
    Edited 7 weeks ago

    Easiest solution is this:
    https://apps.apple.com/de/app/app-language-chooser/id451732904?affId=1864973&ign-mpt=uo%3D4&mt=12

    You can also do it programmatically with declares, to achieve this: (works on iOS, untested on macOS)
    UserDefaults.standard.set(["fr"], forKey: "AppleLanguages") (Change "fr" to the desired language code)

  8. Norman P

    Apr 5 Testers, Xojo Pro outside LMAO !!!!!!!

    Does this declare set it per app or set the users chosen language to French ?

  9. Jeremie L

    Apr 5 Testers, Xojo Pro, XDC Speakers, MVP Europe (France) - packr.app
    Edited 7 weeks ago

    That code will change the language to French, only for the app that runs that code => per app.

    However, the app must be closed then re-opened for the changes to be applied.

    EDIT: that code works for iOS and I assume it works also for MacOS. I haven't tested it as I do not make desktop apps anymore.

  10. @Jeff T how-os-x-chooses-a-language/
    Nope. I have people whose locale should be French but want the app to run in English. Changing the whole system is not viable, even temporarily.

    Jeff, the info on the blog is similar to usage in stackoverflow. If you look at the syntax, "defaults write com.xojo.xojo AppleLanguages -array en", it doesn't change the OS language but rather the specific application language. But there are plenty of articles that to use it on Mojave and Catalina one must elevate the privilege of shell and terminal on the target computer. So that may not work for you in all cases.

  11. Jeff T

    Apr 5 Midlands of England, Europe
    Edited 7 weeks ago

    there are plenty of articles that to use it on Mojave and Catalina one must elevate the privilege of shell and terminal on the target computer. So that may not work for you in all cases.

    And indeed it didn't for me when I tried it on 10.14

    Easiest solution is this:

    Yes, I suspect that may be the best route for me to recommend.

    But I still dont see why Xojo couldnt have a simple switch. It gets resources after asking for the locale.
    It cant be hard to have a locale override, surely?

  12. Beatrix W

    Apr 5 Testers, Third Party Store Europe (Germany)

    Acana App Language is doing the change, so it must be possible. The "defaults write" hasn't worked for a long time.

  13. Norman P

    Apr 6 Testers, Xojo Pro outside LMAO !!!!!!!

    Xojo isnt localized into any languages so that probably plays into why it does not work for Xojo itself

  14. Norman P

    Apr 6 Testers, Xojo Pro outside LMAO !!!!!!!

    @Jeff T It cant be hard to have a locale override, surely?

    its not but requires some work on your part since there's nothing built in

  15. Lee B

    Apr 6 Testers, Xojo Pro Answer

    We use defaults write {BUNDLE_ID} AppleLanguages '("es")' for instance and it works great.

    {BUNDLE_ID} is taken from the Mac Build Settings

    We use the originally proposed hack(Yuck) on PC.

or Sign Up to reply!