You are here

Language Switching Problem (Option File/Java Locale)

17 posts / 0 new
Last post
thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
Language Switching Problem (Option File/Java Locale)

The main problem inhibiting me from submitting Freecol Portable as a Pre-Release right now, is the problem of language switching.

Here's an explanation:

Freecol, in order to determine language for launch, looks at its main option file, and launches based on that. If it's set to automatic or not set, it determines language based on the Java locale.

The problem with updating the language in the option file is that Freecol, when saving options, does not save options with newlines between each one. This makes [FileWriteN] useless.

My question is, is it possible to add newlines using the Replace function, so that a later [FileWriteN] will work? Otherwise, what's the best way to update the Java locale?

(Another, more minor problem with languages, is that the language strings are sometimes labeled with their country. For example, there is no pt language string file included, only a pt_BR and pt_PT.)

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
First Issue Fixed

OK, so it was as easy as I thought: I set the Java locale via -Duser.language, and everything worked.

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

John T. Haller
John T. Haller's picture
Online
Last seen: 25 min 54 sec ago
AdminDeveloperModeratorTranslator
Joined: 2005-11-28 22:21
Second

For the second you can use a language list to redefine the variables that don't match the normal ones.

Sometimes, the impossible can become possible, if you're awesome!

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
Of Course

I forgot about the [LanguageStrings] section! That will make it much easier.

As soon as I finish this, FreeCol Portable should be about ready for Pre-Release.

Thanks, John!

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

Mark Sikkema
Offline
Last seen: 13 years 7 months ago
Developer
Joined: 2009-07-20 14:55
If you have another problem let us know...

I didn't react yet, but was busy on finding a solution for the language setting.

The problem with FreeCol's settings is that it's using XML files for it's settings, and as far as I know there isn't a proper XML plug-in for unicode NSIS (yet).
To solve this, I could make a script what could roughly deal with editing these XML settings, if needed in the future !

Anyway, I'm happy you got it working Smile

Formerly Gringoloco
Windows XP Pro sp3 x32

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
Limited Support

The docs for the Launcher say it does support config files, but it acts like a modified Replace in that it checks the beginning of each line for the string, then replaces the end of the line with the value you give it.

If you could make that script, I'm sure that some other app will need it in the future, and I might use it as a backup.

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

Mark Sikkema
Offline
Last seen: 13 years 7 months ago
Developer
Joined: 2009-07-20 14:55
I'm working on it...

But it probably will not be out very soon.
I'm not having much time lately.

Formerly Gringoloco
Windows XP Pro sp3 x32

OliverK
OliverK's picture
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2007-03-27 15:21
There is a XML Plugin, though

There is a XML Plugin, though not very good. Its use is demonstrated within the screamer portable source

Too many lonely hearts in the real world
Too many bridges you can burn
Too many tables you can't turn
Don't wanna live my life in the real world

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 10 months ago
Joined: 2007-04-15 21:08
Unicode NSIS

The key is Unicode NSIS. I imagine Gringoloco's trying porting one of the existing plug-ins to Unicode.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

OliverK
OliverK's picture
Offline
Last seen: 3 years 10 months ago
Developer
Joined: 2007-03-27 15:21
Eh, okay. I keep forgetting

Eh, okay. I keep forgetting your guy's fascination with unicode

Too many lonely hearts in the real world
Too many bridges you can burn
Too many tables you can't turn
Don't wanna live my life in the real world

Mark Sikkema
Offline
Last seen: 13 years 7 months ago
Developer
Joined: 2009-07-20 14:55
Happily I did find an XML plug-in for unicode nsis !

http://wiz0u.free.fr/prog/nsisXML/
(Although no support for utf-16LE files, if ever needed)

An nsis script appears too slow to deal with an xml file.

Anyway thanx for telling me about Screamer Portable, it gives me another idea what PAL should be able to do. I suspect the plug-in is only needed for lang-switching, but Screamer Portable deals with it in another way again (setting a text vs. an attribute).

To be continued...

Formerly Gringoloco
Windows XP Pro sp3 x32

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 10 months ago
Joined: 2007-04-15 21:08
Thanks

That's another helpful thing for Java apps that I can add to the manual. Smile

(Note for both of us: the Java documentation says it's the two-letter code, so use [Language]:Base=%PortableApps.comLocaleCode2%.)

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
Not From My Experience

From what I've seen, it also supports the glibc locale, with the two letter country code after it. For some languages my app requires it like that.

I'll report again later once I'm on a PC.

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
From the Java Docs

From the Java docs on the definition of a locale:

When writing or talking about locales, you can use a text abbreviation for a convenient representation. This notation separates each component of a locale with an underscore character:

(language code)[_(country code)[_(variant code)]]

So, you can either use just the language code (the one you mentioned) or the language and country code (as I mentioned).

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 9 years 10 months ago
Joined: 2007-04-15 21:08
Don't think so

That's about talking about them. To actually use them, you seem to need to separate them.

Using Locale For example, you can invoke the application like this:

java -Duser.language=fr -Duser.country=CA Default

This invocation prints fr_CA as the default locale.

I am a Christian and a developer and moderator here.

“A soft answer turns away wrath, but a harsh word stirs up anger.” – Proverbs 15:1

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
Will Test It Soon

Apparently, I missed that part, perhaps because I skimmed it while adding the function. I'll test it thoroughly soon (hopefully tomorrow).

Assuming you are right (which you probably are, looking at the docs), isn't that going to be a problem for different dialects (by country) of a language, which usually isn't represented in the two-letter language code? The only working example right now is Portugese (with regular (Portugal) and Brazilian) but that could change as more languages are brought onto the platform.

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

thesupremecommander
Offline
Last seen: 12 years 5 months ago
Joined: 2010-07-03 14:58
It Works Both Ways

After testing it, it seems to work both ways. However, for the sake of being correct, I will change back to the two-letter locale code.

In the future, I suggest that the country and optionally the variant code be added to the Launcher so that we don't lose the ability to display languages in a situation like this (where Brazilian Portuguese cannot be displayed automatically).

(Also, while I'm making suggestions, there is a mistake in the manual: splash.jpg goes in the Launcher folder, not the AppInfo folder.)

My Dev Tests: ~ KeePass Pro Portable (awaiting .NET directory) ~ FreeCol Portable (needs testers)

"... proving to everyone that we are operating on Valve Time..." - us Blum

Log in or register to post comments