nxScribe - Multi language management application (ver 1.0.2)

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

15th Oct 2007. Update - nxScribe version 1.0 beta 4.
Beta 4 (the final one before the first release version) sees the addition of code generation.

nxScribe will now produce a Purebasic source code file which your application uses (with XIncludeFile) to load your language file(s) and retrieve individual language strings.

It handles whetever format of language file you create (Purebasic preferences file, xml utf-8 format or xml utf-16 format) and gives you a choice of how your application is to retrieve it's language strings, namely :

1) through a function call : Language(group$, name$)
or 2) through the use of a global array : gLanguage$().

Option 1) is very flexible and uses a binary-chop to find the required language string etc. so is quite fast. If the required string is not found it just returns an empty string. You also only need to build this PB file once unless you wish to change some of the build options.

Option 2) is blisteringly fast, relying upon an enumerated list of constants which you use for the array indexes. However, this option requires that you rebuild the PB include file every time you make any kind of change to the structure of the underlying language files (else the array indexes could be out of bounds etc).

The choice is yours!

There are additional options such as the use of a default language file (which is packed into the application's executable and used if the application can find none of the specified language files) and these options do need a little care where file paths are concerned.
E.g. any default language file must be in the 'current directory' when the application is being built. At run time (after deployment) the language files are in a folder whose location is specified relative to the application installation folder etc.

Basically I need to get the help manual written! :)

When you have built the PB include file; just XIncludeFile into your application source, doing so very early on in the build. Right at the top of your source if possible.

Call the function : LoadLanguageFile() to load the appropriate language file(s). If this function returns zero then there was an error in trying to load the language file. In this case you would probably decide to terminate your application. It is therefore vitally important to check this return value.


See the first post for the download link.
I may look like a mule, but I'm not a complete ass.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

Thanks srod. I must admit, I'll still poking around with your code output, but I've also briefly looked at gnozal's multi-lingual implementation. I guess your array support is similar to his. I'm not really sure I want to have a bunch of lang files hanging around the application folder. I'd prefer to have all the various languages in a single file that can be bundled in with my source code.
Last edited by mskuma on Mon Oct 15, 2007 10:21 pm, edited 1 time in total.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry mate, I'm not sure what it is you're after?

The folder containing the language files is specified relative to the application installation folder, that is after deployment. So if your application installs in c:\Proram files\MyApp\ for example, then you can specify that the language files are in any subfolder or within this folder itself. I thought this was the best way of keeping things simple.

Gnozal appears, from the code you posted, to place some default language strings directly within the data section of the program. nxScribe does a similar thing, but instead of you having to enter the strings manually, it simply embeds an entire language file within the data section (the default language - if specified). That way, when your application runs, if something goes wrong and your chosen language file cannot be found for some reason, then this default language will be unpacked into a temporary location and used instead. It's kind of a fail-safe option!

Indeed, if you choose not to ship any language files with your application, then you can simply fall back on the default language file which is embedded within the application. This way you could release an English version of your app (with an English language file embedded as the default) or a French version (with a French language file embedded as the default) etc. Not the best way of proceeding but it is certainly one viable method.

As for stuffing all languages within a single file? That's exactly what an nxScribe project file is! However, I have not provided an option for accessing the language strings directly from this project file. I just thought that individual language files was the best way of proceeding when deploying an application etc.

However, I think I will add an option allowing the runtime over-riding of the language file selection.

That is, I'll add a parameter to LoadLanguageFile() so that you can specify a language file in any location; e.g. LoadLanguageFile("c:\Languages\Swahili.lan")

I don't know if this addresses your query?
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

15th Oct 2007. Update - nxScribe version 1.0 beta 5.
Have added an optional parameter to the function LoadLanguageFile() which forms part of the include file generated by nxScribe and used by applications to load language files and retrieve individual language strings etc.

You can now specifiy the name of a language file (at run time) to use and which takes absolute priority over any language files specified when building the include file.

E.g. LoadLanguageFile("c:\English.lan") will load the relevant language file. Unlike the language files specified at the time nxScribe builds the include file, the file path can either be a relative or absolute path. Use LoadLanguageFile() as per beta 4 if you prefer to use the file(s) specified at build time etc.


Please see the first post for the download link.
I may look like a mule, but I'm not a complete ass.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

srod wrote:Sorry mate, I'm not sure what it is you're after?
All language strings in the one file & embedded in the program rather than separate strings external to the application. Your program allows for one embedded language file, and extra languages are external files.
However, I think I will add an option allowing the runtime over-riding of the language file selection.
I guess that is useful, but I think gnozal's overall approach is more elegant because all the strings are already loaded at runtime.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

When I think of a huge application employing, for example, 1000 or more strings, and say supporting 10 languages; that's a lot of data to embed within your application! :) Not only that, you are reading all the strings into memory at runtime, including the languages you are not even going to be using!

For now I think that I will stick with the language file concept because it is a commonly used model and one I am comfortable with. Indeed, the Purebasic IDE, for example, uses this model and it is one I've used time and again without any problem.

Of course I could quite easily add an option to generate a source code file in which all the language strings and in all supported languages are embeded, but I am not convinced that it is a good solution for large projects.
I may look like a mule, but I'm not a complete ass.
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Post by mskuma »

srod wrote:I am not convinced that it is a good solution for large projects.
Yeah you're right. Most of my apps are small, so I didn't think of that issue. Thanks.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Also, with large programs it really does make sense to split the language strings into groups, which would complicate the include file somewhat. Still doable, but embedding loads of groups with loads of strings and with loads of different languages...... arghhhhhhhhhhhhhhhhhhh! :wink:
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

18th Oct 2007. Update - nxScribe version 1.0.0.
This is the first full release as no more bugs have been reported for a while.

I did take the opportunity, however, to upgrade the UI by adding a nice explorer bar gadget. Makes things function a little smoother as well.
(The screenshot looks a little cluttered but that's only because of the image resizing etc. :) )

Please see the first post for the download link.


Image
I may look like a mule, but I'm not a complete ass.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Hi Stephen,

I tried the new version, and 2 things came to my mind:
-the toolbar buttons don't have tooltips, I personally think they're important
-the help toolbar button still has no functionality

Great work...
Windows 7 & PureBasic 4.4
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

If the toolbar buttons are lacking tooltips then that is a bug - theyr certainly did have.

The help button doesn't do anything because I haven't completed the help manual yet! :wink:

I will check the tooltips...
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

The tooltips work fine here!

Can you recheck please.
I may look like a mule, but I'm not a complete ass.
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

I've checked them - no tooltips at all.
I checked in of my projects, too, to ensure that it is not my system,
they work without problems. Seems to be your toolbar...
Running XP SP2 with old Win2K skin...

BTW: I've translated the nxScribe language file to German: http://www.milandot.de/nxScribeCreator.nxScribe
Windows 7 & PureBasic 4.4
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

milan1612 wrote:I've checked them - no tooltips at all.
I checked in of my projects, too, to ensure that it is not my system,
they work without problems. Seems to be your toolbar...
Running XP SP2 with old Win2K skin...

BTW: I've translated the nxScribe language file to German: http://www.milandot.de/nxScribeCreator.nxScribe
Please check your pm.

Thanks for translating the language file; however nxScribe doesn't actually use that language file as it is! :) Remember nxScribe was written before this language file was designed!

I should be able to convert nxScribe across without too much trouble though. :wink:

Thanks.
I may look like a mule, but I'm not a complete ass.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Does anyone else find that the tooltips do not appear?

We cannot get to the bottom of the reason why the tooltips do not appear on Milan's computer.
I may look like a mule, but I'm not a complete ass.
Post Reply