Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.
 Entire forum ➜ MUSHclient ➜ International ➜ How to localize MUSHclient messages into other languages

How to localize MUSHclient messages into other languages

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  3  

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Tue 12 Jun 2007 03:47 AM (UTC)

Amended on Wed 13 Jun 2007 02:18 AM (UTC) by Nick Gammon

Message
Version 4.09 introduces a preliminary attempt at Internationalization (i18n).

I encourage anyone that wants to see a localized version for their language to try to follow the steps described below, and make a version that displays some messages (at least) in their own language.

This version is by no means complete - it was done fairly quickly with a view to being a proof of concept. It is possible that some things were inadvertently changed for the worse. Perhaps some existing messages will not be displayed correctly. If that happens, please advise the exact thing you were doing, and if possible compare to an earlier version to find what the message used to say.

Things NOT changed

This version does not have any changes to the "resource" part of the executable, in particular menus and dialog boxes will still be in English, and there is no provision for changing them. That should be possible to do by editing the resource files (which are publicly available) and making new versions marked as being appropriate for a new locale. These (when available) can be merged into the existing executable, in future releases.

[Edit] See below - version 4.10 now allows this.



How to localize


  1. You should find - as a subdirectory to where MUSHclient is installed - a directory called "locale". In that will be a file "Localize_template.lua".

  2. Copy (or rename) that file to be xx.lua, where xx is your locale identifier. (eg. EN for English, ES for Spanish, DE for German, FR for French).

  3. Check that MUSHclient has correctly deduced your locale by starting it up, and going to File -> Global Preferences -> General. Near the bottom corner is a new field "Locale code". Make sure that this agrees with the code you have chosen for the localization file (Eg. EN, ES, DE, FR). If not, change it. :)

  4. Edit the localization file with a text editor that supports UTF-8 encoding. For example, Crimson Editor: http://www.crimsoneditor.com/

    If you are using Crimson Editor make sure that the Document Encoding Type is set to UTF-8 Encoding (w/o BOM). See the Document menu -> Encoding Type.

  5. Review the English messages, and make translations where you feel is appropriate.

    For example, right near the start of that file are these lines:

    
    -- DDV_validation.cpp:41
      ["This field may not be blank"] =
        "",
    


    You can put in a translation by changing the empty string to show the translated version, like this (I did this with Google translate, so bear with me if it came out as nonsense):

    
    -- DDV_validation.cpp:41
      ["This field may not be blank"] =
        "Dieses fangen kann möglicherweise nicht leer sein auf.",
    


  6. Save the changed xx.lua file.

  7. Close MUSHclient if necessary (completely, not just the current world).

  8. Restart MUSHclient. At this stage it should notice the xx.lua file and process it. If there are syntax errors in it you will get a message now.

  9. If you made the suggested change above, you can confirm it worked by going to the Connection menu -> Quick Connect. Hit <enter> without entering a TCP/IP address, which will trigger off the message above ("This field may not be blank").

  10. You should now see the translated message instead.

  11. You can now re-edit the xx.lua file and make further translations. Remember to save it, and restart MUSHclient, in order to test them.




Different sections in the localization file

The localization file is currently split into four different sections. Each consists of a Lua table, the key of each item of which is the original message (in English) inside MUSHclient.

The four sections are:


  1. messages - these are "static" messages (error or advisory messages). They are static in the sense that they don't change at runtime, and thus can be translated as a unit. For example, the message "This field may not be blank" will always be exactly that.

    Thus, the translation in the "messages" section is simply a string, which is the translated message.

  2. formatted - these vary at runtime. For example, the message "Line number must be in range 1 to %i". In this case the upper limit varies, and thus the message cannot be translated into a static string.

    For formatted message there will be a "replacement" sequence indicated by %x where x is a formatting character. Consult the string.format documentation inside MUSHclient for possible replacement sequences. For example, %s is a string, %i is an integer, and %f is a floating-point number.

    Because some work may be needed to get a good translation, each message in this section calls a function, and the responsibility of that function is to do the translation, incorporating the variable fields.

    Let us assume that we are translating into Spanish for the moment, and that a good translation would be "La línea número debe estar en la gama 1 a %i."

    First, we locate the templated message:

    
    -- GoToLineDlg.cpp:45
      ["Line number must be in range 1 to %i"] =
        function (a)
         
          return ""
        end,  -- function
    


    The xx.lua file already has a function definition, and it has worked out that we have one variable, which it has named 'a'.

    So, to translate it into Spanish we could do this:

    
    -- GoToLineDlg.cpp:45
      ["Line number must be in range 1 to %i"] =
        function (a)
         
          return string.format (
            "La línea número debe estar en la gama 1 a %i.", a)
            
        end,  -- function
    


    We use string.format, which is a Lua function that lets us imbed things into a string, and supply the variable (a) as an argument.

    Having made this change, and restarted MUSHclient, we can go into the inbuilt notepad, press Ctrl+G to "go to line", and enter a line out of range (eg. 1000). You should then see the translated message appear, with the correct range incorporated into the message.

    Some messages may require more work, for example something like "loaded %i alias%s". Here we have a number (eg. 10), and if the number is not 1, then the second variable (%s) would have "es" in it, so the message would read "loaded 10 aliases".

    To translate that into another language, you would have to look at the variable which has the number in it, and take appropriate steps to "pluralize" the noun.

    If one of these translation functions has a run-time error (for example, concatenating a string with nil), then a dialog box will appear at runtime, at the moment that the message would have appeared, describing the nature of the error. Then, since the function has failed, the original message, in English, will be displayed.

  3. times - these are for formatted date/time strings. You may need to look at the source code to see the context . For example:

    
    -- doc.cpp:6767
      ["--- Connected on %A, %B %d, %Y, %#I:%M %p ---"] =
        "",
    


    For the "times" messages the fields starting with "%" are date/time fields. See the documention for os.date for an explanation.

    You may want to translate any English words (eg. "Connected on") plus revamp the order in which the date/time fields appear.

  4. headings - these are generally one-word fields which are used in the various "list" dialogs (like the list of plugins). By changing the translations here you can change the column headings. For example you might change "Author" to "Autore" (Italian).

    Thus, a changed entry might look like this:

    
    -- PluginsDlg.cpp:105
      ["Author"] =
        "Autore",
    





Notes


  • Any entries you don't change will continue to appear in English. Thus, if you don't mind a bit of a mixture of English and your chosen language, only translate the messages that appear often enough that you wish they were translated.

  • Since the entire localization file is a Lua source file, feel free to use comments, make special functions to handle things that are done often (like making words plural), and generally organizing it the way you want to.

  • You have access to the standard Lua libraries, plus MUSHclient extension libraries "rex", "bit", "utils", and "bc".

  • You can use the information about the source file, and line number, to read the MUSHclient source, and find out more about the context in which a particular message appears.

  • Some messages are displayed in the output window. If you are using Unicode characters then make sure that you have UTF-8 enabled in the world configuration "Output" section, and that you have chosen a font that displays Unicode characters.

  • Feel free to post messages announcing your intention to translate into a certain language. You may find other people interested in collaborating with you - for example, to each do a part of the file.

  • Please do not spend weeks of work translating just yet - the format of the file may be fine-tuned yet, depending on comments we receive from the initial attempts. Also, the file is very likely to be expanded with new entries.

  • Do not change the "key" text - the stuff inside the square brackets. If you do so, it will no longer match, and become ineffectual.

  • Any messages that are not in the table at all, or return an empty string, will default to the original English message being displayed.

  • There are probably parts of MUSHclient that have not yet been converted to use the translation process. Please advise any such messages that you think should appear in the localization file.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 12 Jun 2007 04:10 AM (UTC)

Amended on Tue 12 Jun 2007 04:37 AM (UTC) by Nick Gammon

Message
If you want to experiment with localizing, you can download version 4.09 (1.91 Mb) from here:

http://www.gammon.com.au/files/mushclient/mushclient409.exe

This should be regarded as an experimental version - don't bother downloading it unless you are going to play with localizing it, and don't mind if things go wrong.

The sumcheck for this file is: 0c4b0c6c2828ccb3e2a0dff6c1bf9eb0

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hairui   China  (24 posts)  Bio
Date Reply #2 on Tue 12 Jun 2007 02:20 PM (UTC)
Message
Maybe the message in the resource part is more important than the other ones for us to use the MushClient.I am eager for the version which "resource" part of the executable can be localized in an easier way. But I know I must take pains before the weeks of hard work on that.

Thanks Nick for his effort in the past week.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #3 on Tue 12 Jun 2007 09:13 PM (UTC)
Message
OK, I see, but I thought from the screenshot that you posted that the resource part was basically solved.

I'll do some more research into how that might be achieved along similar lines to the text messages, however resources are compiled into some sort of binary form by the resource compiler.

I can imagine it won't be too easy to simply automate it by reading strings from a file. In some of those dialogs the various check boxes are squeezed fairly tightly together, and if the wording became longer it might be chopped off.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Hairui   China  (24 posts)  Bio
Date Reply #4 on Tue 12 Jun 2007 10:17 PM (UTC)

Amended on Tue 12 Jun 2007 10:34 PM (UTC) by Hairui

Message
I have asked the man who localized the resource part about the localizing method . The answer is editing the binary code of mushclient.exe by some tools manually. But since the frequence of the version updating is so high that he can not localize the up to date version in time, the latest localized version is 4.01 now.

Maybe a binary editing tools is needed ,by which we can search the text to localize in the mushclient.exe , get its localized text from a dictionary like text file and exchange them automatically. It seems that the key to solve the problem is the algorithm of compiling the text message into binary form.
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #5 on Tue 12 Jun 2007 11:39 PM (UTC)
Message
I am investigating separating out the resources into a separate DLL.

If successful, then the program can load the appropriate DLL at runtime, which will give the localized menus, dialogs etc.

This DLL would not need to change for mere code changes in the client (like bugfixes, or changes to scripting). For more major changes (like a new dialog box), then hopefully you could copy the new dialog from the English version, customise it, and paste into the localized version.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #6 on Wed 13 Jun 2007 02:34 AM (UTC)

Amended on Tue 16 Aug 2011 08:40 PM (UTC) by Nick Gammon

Message
Separate resource file

MUSHclient version 4.10 now separates out its resources into a separate DLL. This allows you to localize the resources separately from the program code.

Effectively, this would let you have a different GUI interface for any language you choose, with the core functionality staying the same.

This is intended to work in conjunction with the string localizing described above.

The resources are things like menus, dialog boxes, and some strings.

What version 4.10 (onwards) does is look in the locale subdirectory (as described above for the string localizing), and expects to find a file xx.dll. This is the resource file for the current locale.

For example, if the locale is English, you should have in the locale directory:


en.lua - string localization
en.dll - resource localization


MUSHclient cannot start if it does not find the localized dll, as all the menus, dialogs etc. are in it.

However, if the locale is other than English, it first tries the requested locale (Eg. DE.dll) and if that fails, retries looking for EN.dll. That gives a fallback position, in case you accidentally change the locale to something other than EN, but have not installed a different DLL.

Version 4.10 is available (1.90 Mb) from:

http://www.gammon.com.au/files/mushclient/mushclient410.exe

Its sumcheck is: 91be3a11ce1df9aa2e45f86528cb6cb9

This download includes the en.dll for the English localization.




How to localize the resources

I believe there are resource editors around that let you edit DLLs and simply change the resources. If you can find one, simply make a copy of en.dll (eg. as de.dll). Then edit the copy, making such changes as you see fit.

Alternatively, you can download the source files used to build the resource dll. These are available (269 Kb) from:

http://www.gammon.com.au/files/mushclient/resources/mushclient_resources_4.10.zip

The sumcheck for this file is: 78851ba0b216161e1042a9dc684be89e

Inside that file is a Visual Studio project, which if you build it, should generate the resources file for version 4.10.

[EDIT] Now available from:

https://github.com/nickgammon/mushclient_resources

You can then simply edit the resources using Visual Studio (or any other tool that works), and rebuild with the amended resources. You could try using Visual Studio Lite which is a free download from Microsoft.




Do I have to do that for every new release?

No, hopefully not. The resources part tends to change slowly, as they are basically dialogs and menus. An amended resource file should continue to work with future versions, unless such version incorporates major changes, like amendments to dialog boxes, or new ones.

If you work with the Visual Studio project mentioned above, the resources are in text form, and you could do a "diff" to compare a new release with an earlier one. That would quickly show which ones have changed, and thus only the changed ones would need to be amended (relocalized).




I am interested in getting any feedback about how well this works. It is possible that something important got omitted in the process of splitting MUSHclient into two parts - code and resources, so this should be regarded as an experimental version.

If all goes well, then people are welcome to submit localized versions of the resource dll, so that they can be shared with other MUSHclient users.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Wed 13 Jun 2007 02:47 AM (UTC)
Message
What kind of security is there for user-submitted resource DLLs? More specifically: can a DLL that is supposed to only contain localized resources also contain arbitrary code? I trust code that comes from you and some users but not necessarily precompiled DLLs submitted by users I don't know. How easy is it for users to submit localized resource DLLs that the end-user can compile themselves after checking source code?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #8 on Wed 13 Jun 2007 03:23 AM (UTC)
Message
The DLL is loaded using LoadLibrary and then set as the application resource handle.

I'm not sure whether any arbitrary code could be activated in any way, although probably the LibMain function which I presume is called as part of the loading process could.

For the end-user to compile them they would need a compiler - not every MUD player would have one.

If people go down the route of downloading the resource script and amending that, they could resubmit that to me for compilation and inclusion on this site.

However the version submitted by an earlier poster, who submitted a screen shot of a customized MUSHclient executable, could presumably have added malicious code to it, if the person doing it wanted to. So those particular users are not any worse off.

There is a similar issue with the lua string localization. So far I haven't attempted to disable things like the io library in Lua, for that particular file. Perhaps I should.

You could argue that localizing strings doesn't require operating system calls, or file IO.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #9 on Wed 13 Jun 2007 03:31 AM (UTC)
Message
Ah, ok. For DLLs it looks like the main issue is the LibMain function. Maybe a prerequisite of a new resource DLL being published on this site could be a check-over of the source by either yourself or designated community members? I would feel a lot more comfortable about localization DLLs if I had confidence that they'd been checked over by somebody I trust.

As for the Lua localization, I think you are right, sandboxing the file to remove e.g. os and io would be a good idea.

This localization effort is pretty cool. :-) I would be happy to contribute to a French localization if there is demand for one. (To be honest, though, I don't know any MUD terms in French... e.g. "MUD" itself! (DMU? Donjon a Multiples Utilisateurs?))

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #10 on Wed 13 Jun 2007 04:06 AM (UTC)
Message
Yes I agree I wouldn't want to publish a DLL on this site, without viewing its source. What the general MUD community does is its own affair. Perhaps a German MUD might produce its own localized file, so if you trust the MUD admins, you trust the file.

As for the French version, even if you were to try localizing a couple of dialog boxes, and a couple of error messages, just to confirm I have the general technique right, that would be helpful.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #11 on Wed 13 Jun 2007 06:01 AM (UTC)

Amended on Wed 13 Jun 2007 06:12 AM (UTC) by Nick Gammon

Message
New version released - 4.11

As expected, there were some teething problems with the process of separating the resources from the code. In particular, a couple of places where the resource file was manually interrogated for text, such as the license agreement, and the program credits, stopped working because it was looking in the wrong place.

Also, I have tightened up the Lua environment for the localization processing. I can't see any need for localization code to do things like delete or write files, for example.

I also noticed that with all the resources moved into the resource file, the program file didn't even have a nice icon any more. So, this has been put back.

The new version is now available (1.91 Mb):

http://www.gammon.com.au/files/mushclient/mushclient411.exe

Sumcheck for the MUSHclient installer is: 8c978231db5d7f89da953431bbb0cf05

The resource localization file (146 Kb) is here:

http://www.gammon.com.au/files/mushclient/resources/mushclient_resources_4.11.zip

Sumcheck for the localization file is: 43cc0de5f0fe094f4f156e6b56cd43e3

I don't think the resources have changed much. This file is smaller than the previous one because it no longer has a copy of en.dll in it. This ships with MUSHclient anyway.

See the release notes for a full list of changes:

http://www.gammon.com.au/scripts/showrelnote.php?version=4.11&productid=0

The source for version 4.11 is now available (1.90 Mb):

http://www.gammon.com.au/files/mushclient/src/mushclient_4.11_src.zip

Sumcheck for the source is: eea5868afdcd0d196637193ad2c4a664

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #12 on Wed 13 Jun 2007 06:22 AM (UTC)
Message
Quote:

(To be honest, though, I don't know any MUD terms in French... e.g. "MUD" itself! (DMU? Donjon a Multiples Utilisateurs?))


From Google Translate:

Cachot multiple d'utilisateur

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #13 on Wed 13 Jun 2007 06:30 AM (UTC)
Message
Quote:
Cachot multiple d'utilisateur
Haha -- now that just doesn't make any sense. :-)

An interesting note is that "donjon" in French does not actually mean "dungeon", rather it means "keep", as in the central fortified keep of a castle. I guess that "dungeon" in English came to mean what it means due to the fact that the dungeons are, indeed, usually in the keep. Or maybe it was just confusion during ol' William the Conqueror's stay in England.


I'll give a shot at localizing the resource files. However, I don't have MSVC on this system (I run Linux). Is it ok if I send back modified the resource file?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,120 posts)  Bio   Forum Administrator
Date Reply #14 on Wed 13 Jun 2007 06:34 AM (UTC)
Message
Sure. Just edit the mushclient.rc file and make whatever changes you want.

I have a suspicion we will yet have troubles because MUSHclient is not a Unicode application.

I am not sure what will happen if you try to incorporate characters whose code is > 127.

Perhaps the resource file can be Unicode and the rest not - I don't know.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


157,661 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.