You are here

Language Switching

14 posts / 0 new
Last post
Jacob Mastel
Offline
Last seen: 2 years 4 months ago
Developer
Joined: 2007-06-13 19:36
Language Switching

John and I have been discussing how to encorporate language switching into Stickies. Unfortunately the app handles language switching in a rather odd manor. When it's launched it checks it's running directory for a file called "language70.dll". If that file is found it will pickup whatever language is contained; if there is no file it defaults to English.

On IRC John said that

Basically, you check to see if it's set, then delete the lang that is there (if there is one). Then, if the lang is English, do nothing. If it is something else, copy it in. Then write out the current lang to the StickiesPortableSettings.ini file for next time, so you can check if it changed or not.
That way, if it hasn't changed, you can avoid copying something else in. Becuase PAL will always try to switch it to English otherwise.

He said that he believed an existing app used that method, does anyone know which that is or have existing code that can be just cloned over?

OliverK
OliverK's picture
Offline
Last seen: 1 year 7 months ago
Developer
Joined: 2007-03-27 15:21
PNotes Portable? It uses

PNotes Portable? It uses *.lang files, but its pretty close . . .

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

scriptdaemon
Offline
Last seen: 3 years 2 months ago
Developer
Joined: 2008-10-10 17:40
.

I have this same predicament for Dimio's apps (DShutdown, DTaskManager, etc.). Honestly, I think it might need some custom code regarding FilesMove since it's relative to the data directory.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 7 years 7 months ago
Joined: 2007-04-15 21:08
Like this

Here's my answer for scriptdaemon, for DShutdown (as he emailed me asking about it). It'll be very similar for other apps, just with some different paths. (Scriptdaemon: note I've also changed your App\DShutdown\DShutdown English Pack\DShutdown.lng to just App\Languages\English.lng; seems neater to me and you can more easily filter it for the optional section in the installer too. Your choice on how you do it.)

Store the language name in %PAL:DataDir%\settings\DShutdownPortableSettings.ini, section DShutdownPortableSettings, key Language. Then you'll be able to switch over to [Language]:SaveLanguage=true which I'll be putting in PAL 2.2 for cases like this (and ones which use an environment variable).

Then here's some code.

launcher.ini:

[FileWrite1]
File=%PAL:DataDir%\settings\DShutdownPortableSettings.ini
Type=INI
Section=DShutdownPortableSettings
Key=Language

[Language]
Base=%PortableApps.comLocaleName%
CheckIfExists=%PAL:AppDir%\Languages\%PAL:LanguageCustom%.lng
DefaultIfNotExists=English

[LanguageFile]
File=%PAL:DataDir%\settings\DShutdownPortableSettings.ini
Type=INI
Section=DShutdownPortableSettings
Key=Language

Custom.nsh:

${SegmentFile}

${SegmentPrePrimary}
	ReadEnvStr $0 PAL:LanguageCustom
	Rename $AppDirectory\Languages\$0.lng $AppDirectory\DShutdown\DShutdown.lng
!macroend

${SegmentPostPrimary}
	ReadEnvStr $0 PAL:LanguageCustom
	Rename $AppDirectory\DShutdown\DShutdown.lng $AppDirectory\Languages\$0.lng
!macroend

(Incidental note: this is safe in case of power failure, crash, etc. as well.)

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

scriptdaemon
Offline
Last seen: 3 years 2 months ago
Developer
Joined: 2008-10-10 17:40
Awesome.

Small question though, what's the benefit of having App\Languages instead of App\DShutdown\Languages? Is that due to the fact the languages don't come with the app by default?

EDIT: Tried it out and the custom code doesn't seem to be working. Is the PAL:LanguageCustom variable built before PrePrimary?

EDIT 2: I don't think that matters as it still doesn't work even when I hardcode a language into the custom code.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 7 years 7 months ago
Joined: 2007-04-15 21:08
App\Languages vs.

App\Languages vs. App\DShutdown\Languages? There's no real difference between them... App\Languages is just shorter.

Make sure you've got the file in the right place: App\AppInfo\Launcher\Custom.nsh for 2.1. You can also put in MessageBox lines to check that it's happening.

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

scriptdaemon
Offline
Last seen: 3 years 2 months ago
Developer
Joined: 2008-10-10 17:40
Ah.

The manual still says that file goes in Other\Source. It's working now.

What exactly is the purpose of adding [Language]:SaveLanguage=true?

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 7 years 7 months ago
Joined: 2007-04-15 21:08
2.0

2.0 had it in Other\Source\PortableApps.comLauncherCustom.nsh. 2.1 has it in App\AppInfo\Launcher\Custom.nsh.

[Language]:SaveLanguage=true (might change that key to Save) will be equivalent to the FileWrite1+LanguageFile; it's just for simplicity in the launcher configuration as it's not related to the actual app, only to internal stuff with the launcher.

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

Jacob Mastel
Offline
Last seen: 2 years 4 months ago
Developer
Joined: 2007-06-13 19:36
Still a little lost

Do you mind taking a look at this. It's what I've got done so far, and it's not really doing anything...

Release Team Member

scriptdaemon
Offline
Last seen: 3 years 2 months ago
Developer
Joined: 2008-10-10 17:40
.

1. Your custom code should be in App\Appinfo\Launcher\Custom.nsh

2. Also, it should instead be

${SegmentFile}

${SegmentPrePrimary}
	ReadEnvStr $0 PAL:LanguageCustom
	Rename $AppDirectory\Languages\$0.dll $AppDirectory\Stickies\language70.dll
!macroend

${SegmentPostPrimary}
	ReadEnvStr $0 PAL:LanguageCustom
	Rename $AppDirectory\Stickies\language70.dll $AppDirectory\Languages\$0.dll
!macroend

3. Rename App\languages to App\Languages

4. In launcher.ini, the [Language] section should be changed to

[Language]
Base=%PortableApps.comLocaleName%
CheckIfExists=%PAL:AppDir%\Languages\%PAL:LanguageCustom%.dll
DefaultIfNotExists=English

5. And you'll need a [LanguageStrings] section that contains all available languages, because currently %PortableApps.comLocaleName% returns strings in all capital letters, and files are case sensitive.

Chris Morgan
Chris Morgan's picture
Offline
Last seen: 7 years 7 months ago
Joined: 2007-04-15 21:08
Case insensitive

On Windows all paths are case insensitive. For this, you don't need to worry about case. Granted, it will turn e.g. English.dll to ENGLISH.dll after it's been used, but that doesn't matter.

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

Aciago
Aciago's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2007-01-24 14:23
App\Languages vs. App\DShutdown\Languages

I have a question, and I have three ways to ask the same think, since English is no my main language (and today I'm "English mentally blocked"), I'm going to ask twice the same think to make me more understandable...

This means that App\Languages will reduce the total size of files stored in the portable drive, but only if every app is going to use it, so those apps which already comes with different lang files should be edited to remove those lang files... so PortableApps.com will not be "the same app" anymore. Otherwise we are going to have a lot of redundant files (almost as we already have)... Sad

But this means that applications like GIMP, OpenOffice, Filezilla which have their own lang files (already comes in the old fashioned App\DShutdown\Languages way) will have to be edited to remove those redunded lang files?

Do you mean that the current lang file of an app will be moved to App\Languages folder? because this makes it easier to me to locate them and delete it all (except English and Spanish) but is dangerous since two apps can have the same file name but not the same content/format and one can replace the other one and mess the entire think.

If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

Simeon
Simeon's picture
Offline
Last seen: 8 years 3 months ago
DeveloperTranslator
Joined: 2006-09-25 15:15
no

I think you misunderstood something here. This is only for one app which needs special language file handling and not for all others. All other apps will remain the way they are.

"What about Love?" - "Overrated. Biochemically no different than eating large quantities of chocolate." - Al Pacino in The Devils Advocate

Aciago
Aciago's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2007-01-24 14:23
Oops!

Sprry, I understood that "the platform" was going to have this feature to use it to the whole pack of portableapps.

If a packet hits a pocket on a socket on a port,
and the bus is interrupted as a very last resort,
and the address of the memory makes your floppy disk abort,
then the socket packet pocket has an error to report Biggrin

Log in or register to post comments