[Mod] Internationalization Library [intllib]

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by kaeza » Sun May 08, 2016 20:33

Glory! wrote:WTFPL.

Thank you. Added note to first post.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

cimbakahn
Member
 
Posts: 36
Joined: Sat Aug 29, 2015 20:03
IRC: cimbakahn
In-game: cimbakahn

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by cimbakahn » Sat May 14, 2016 22:36

Hello Xanthin

I do believe the awards mod is supported as well, so you can add it to your list of intllib supported mods.
 

cimbakahn
Member
 
Posts: 36
Joined: Sat Aug 29, 2015 20:03
IRC: cimbakahn
In-game: cimbakahn

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by cimbakahn » Sun May 15, 2016 10:41

Shoot! I just realized, i could be wrong. awards coughs up this message: WARNING: Undeclared global variable "intllib" accessed at ...kahn/.minetest/mods/dreambuilder_modpack/awards/init.lua:8 I thought the fact that awards knew anything about intllib ment it was supported, now i am not so sure?
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by kaeza » Sun May 15, 2016 16:58

cimbakahn wrote:Shoot! I just realized, i could be wrong. awards coughs up this message: WARNING: Undeclared global variable "intllib" accessed at ...kahn/.minetest/mods/dreambuilder_modpack/awards/init.lua:8 I thought the fact that awards knew anything about intllib ment it was supported, now i am not so sure?

That warning just means `awards` is probably not (optionally) depending on `intllib` (`awards` probably gets loaded before this mod or there's something weird going on, so the global `intllib` table is not set yet). You should contact the mod's author (rubenwardy) or the game author (VanessaE) to issue a fix.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by rubenwardy » Sun May 15, 2016 20:57

I'll fix this, I've never actually tested it sorry :P
 

Emon
Member
 
Posts: 48
Joined: Tue Apr 26, 2016 09:35

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by Emon » Tue May 17, 2016 13:40

List of mods using Intllib

The call has been made, will you join us to conquer the world? ;)

Kaeza, thanks for this mod!
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by Wuzzy » Sat Aug 06, 2016 23:21

Hey, I have problem with whitespace.

I want to add a string with trailing space or leading space but I can't translate it. The mod documentation claims I can declare space with the special character “\s” but it doesn't seem to work. Here's a minimal example:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local S
if (minetest.get_modpath("intllib")) then
   dofile(minetest.get_modpath("intllib").."/intllib.lua")
   S = intllib.Getter(minetest.get_current_modname())
else
   S = function ( s ) return s end
end

minetest.register_craftitem("spacetest:lead", {
   description = S(" Space")
})

minetest.register_craftitem("spacetest:trail", {
   description = S("Space ")
})


And here's a translation file (locale/de.txt):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
\sSpace = \sLeer
Space\s = Leer\s


Sadly, intllib does NOT translate the item names. What is wrong? (Btw, I downloaded new intllib version just today.)

PS: Not really wanting to rush you, but is there any chance there will be another official intllib release after only 3 years? :P


PPS:
kaeza wrote:Dependencies: default

Huh?
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

Xanthin
Member
 
Posts: 121
Joined: Fri Mar 07, 2014 14:05
GitHub: Xanthin
IRC: Xanthin
In-game: Xanthin

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by Xanthin » Sun Aug 07, 2016 08:29

I hope I understand you correct, Wuzzy.

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
\ \Space = \ \Leer
Space\ \ = Leer\ \


That's what I use in those situations.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by Wuzzy » Sun Aug 07, 2016 15:05

Xanthin, it worked.
WTF, why? It shouldn't work, this is totally not what the documentation said. This seems to be a bug in the mod.
The documentation says I must use “/s”. ]:-(
But thanks for your solution.

But why the backslashes before “L” and “S”?
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by kaeza » Sun Aug 07, 2016 17:38

Wuzzy wrote:this is totally not what the documentation said. This seems to be a bug in the mod.
The documentation says I must use “/s”.

It's not a bug... it's a feature!

Sorry, will fix it Real Soon™.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [0.1.0] [intllib]

by Wuzzy » Thu Nov 03, 2016 23:28

Thanks for fixing /s in the meanwhile, even if you don't talk much on these forums. :D

Can you please take the current version of intllib and just call it “version 0.2.0”? People on these forums will tend to think this mod is dead since the version number is stuck on 0.1.0 for so long (it took me long for ME to realize this mod is actually NOT dead). It doesn't need to be perfect, just give players out there a signal that this mod is still alive. ;-)
Alternatively, if you are lazy, you could rename the thread to “[Mod] Internationalization Library [Git] [intllib]” if you don't feel like making official releases at all (You link to HEAD, after all, and not a particular revision). This is less work for you, but on the downside, users never really know when there are updates.

Please add the usual metadata files (description.txt, mod.conf; see lua_api.txt for more info).

Also, please remove the “dependency: default” nonsense from the first post. This is clearly incorrect. Your mod has actually no dependencies (I tested it by using it without Minetest Game / the default mod and it worked just fine).


EDIT:
Also, thanks for the work on this mod. In the past I have included intllib support for many of my mods. I am glad that this mod now includes a basic toolchain to extract and update the strings. This is very important IMO since manual string extraction is VERY tedious (and error-prone).
Intllib works well for singleplayer but users must be aware that this mod is not very well suited for servers. Server operators must be aware that using intllib forces the server langague on every client, e.g. if server is Spanish, ALL clients will receive Spanish messages.

Although I think the ultimate goal of Minetest should be to add native mod translation support, I think this mod is useful for the meantime for singleplayer use. Another reason why I include intllib support for my mods is that for the time when mod translation support finally arrives, I probably only have to change the boilerplate, but the texts are already translated. :-)
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [intllib]

by kaeza » Fri Nov 04, 2016 00:41

Edited the post to address some of your points. Also added the metadata as requested. `lua_api.txt` was not of much help regarding `description.txt`, but found some help here. Tell me if something's wrong.

For some reason phpBB does not update the last edited date of posts when a moderator does it, and too lazy/uninterested to look for a way. I added a note to the first post to this effect.

I'm really glad people find this mod useful, and I should thank you and all the modders who provide support for `intllib` in their mods, and their respective translators, for making Minetest better.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [intllib]

by Wuzzy » Fri Nov 04, 2016 02:49

Thank you. I think the description is OK. The description.txt is used by Minetest in the main menu, tab “Mods”. Yeah, description.txt is really that simple: Just a short text file containing a description of the mod. If it renders correctly in the main menu tab, then your description is probably OK. Rubenwardy's advice is unofficial as far I know.

This file is also used by other applications. For instance, Minetest Bower uses it to show the description in the search results.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [intllib]

by Wuzzy » Tue Nov 08, 2016 16:45

Sadly, this mod breaks when mod security is on. :-(
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [intllib]

by kaeza » Tue Nov 08, 2016 22:33

Wuzzy wrote:Sadly, this mod breaks when mod security is on. :-(

Hm? I have mod security on and have no problems.

What's the error?
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Oh crap!

by Wuzzy » Wed Nov 09, 2016 00:10

Oh crap, oh crap, oh crap, oh crap, oh crap, oh crap, oh crap, oh crap, oh crap, oh crap!

I just made some tests.
First, I tested intllib alone in the Empty subgame (subgame without mods). It works.
Now I added one dependant mod: teletool.

And ta-da! The error appears. This is the error you asked for:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
2016-11-09 00:13:32: ERROR[Main]: ModError: Failed to load and run script from /home/wuzzy/src/minetest/git/minetest/bin/../mods/teletool/init.lua:
2016-11-09 00:13:32: ERROR[Main]: Attempt to access external file /home/wuzzy/src/minetest/git/minetest/bin/../mods/intllib/intllib.lua with mod security on.
2016-11-09 00:13:32: ERROR[Main]: stack traceback:
2016-11-09 00:13:32: ERROR[Main]:    [C]: in function 'dofile'
2016-11-09 00:13:32: ERROR[Main]:    .../src/minetest/git/minetest/bin/../mods/teletool/init.lua:3: in main chunk
2016-11-09 00:13:32: ERROR[Main]: Siehe debug.txt für Details.


And what is at line 3 of teletool/init.lua, you ask? Look here:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local S
if (minetest.get_modpath("intllib")) then
   dofile(minetest.get_modpath("intllib").."/intllib.lua")
   S = intllib.Getter(minetest.get_current_modname())
else
   S = function ( s ) return s end
end

(full source code)

The offending code is quite obviously the “dofile”. This is a blatant violation of mod security because a file from outside the teletool mod is attempted to be loaded.
Oddly, this is not even the boilerplate code from the intllib README. But when I looked on earlier versions of intllib, the dofile was still there. Probably the code here was just copied from an older version of intllib.
When I use the new intllib boilerplate, it works fine. The fix is (luckily) quite simple.

But the “Oh crap!” part of this is that I have found many mods in my mod directory which currently contain the bad “dofile”:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
awards
food_sweet
homedecor
maptools
prehistoric_modpack

bedrock2
dice2
doc_minetest_game
hbarmor
hbhunger
hudbars
inventory_icon
magicbeans_w
mana
mtg_plus
orienteering
origin
pedology
pep
pseudonodes
returnmirror
teletool
tsm_surprise
wateringcan


All these listed mods will break with mod security AND intllib enabled. Quite a sneaky bug. And yes, many of my own mods are on the list! :-(

But I have planned to do a Minetest mod release orgy in this or the next week anyway. I will “spam” the forums with mod updates at this time. So I am quite glad I found the bug BEFORE that. :-)
Last edited by Wuzzy on Wed Nov 09, 2016 01:46, edited 1 time in total.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [intllib]

by kaeza » Wed Nov 09, 2016 00:55

Yeah, changes always break something. Only solution is to nudge these modders a bit to update their mods.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [intllib]

by Wuzzy » Wed Nov 09, 2016 02:48

Whew. I just updated all my affected mods. They should now all work with intllib AND mod security enabled.
Some of the mods not from me were just outdated on my macihine. After an update, the bug was gone. I informed the authors of the remaining mods.

It looks bad. Very, very bad. A GitHub search for the offending code gives over 500 results:
https://github.com/search?utf8=%E2%9C%9 ... rchresults

There are some false-positives here, but many hits are justified. But on GitHub many projects are also just dead, those can be ignored as well.

Still, this does not look good. :-(
It would take ages to inform all the modders. It seems that basically all mods which supported intllib early on are basically broken.
Just fixing mods is not enough. Modders must be made explicitly aware of the change. I bet many modders just copy-paste the boilerplate code from another mod because they are too lazy to open GitGub. xD And so the broken code spreads. :-(

And yes, you are right. The breakage was required. There was no other way. Sadly. :-( The alternative would be having no mod security. Which is of course crazy. ;-)

I bet the real fun begins when the next Minetest gets released. Then, mod security is enabled by default. xD

Sigh. I fear it will be a lot of work to fix all those mods. Let's hope not too many modders abandon Minetest too early.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
ShadowNinja
Member
 
Posts: 194
Joined: Tue Jan 22, 2013 22:35
GitHub: ShadowNinja
IRC: ShadowNinja
In-game: ShadowNinja

Re: Oh crap!

by ShadowNinja » Thu Nov 10, 2016 02:37

Wuzzy wrote:[intllib-using mods fail security tests]
Oddly, this is not even the boilerplate code from the intllib README. But when I looked on earlier versions of intllib, the dofile was still there.
[I wrote patches to fix a bunch of the affected mods]

The dofile was basically just a way to make sure intllib was already loaded, but Minetest already has a mechanism for that: depends.txt. So I removed that hack and now you're just supposed to add intllib to depends.txt -- although I left the old intllib.lua file there for compatibility. Just make sure you add that the depends.txt line in your patches if it isn't already there.
I play on my Minetest server and VanessaE's.
The best way to contact me is usually IRC (InchraNet, freenode).
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: [Mod] Internationalization Library [intllib]

by Wuzzy » Thu Nov 10, 2016 13:31

Ah, thanks for the background on this. And yeah, all my intllib-dependant mods have “intllib?” in depends.txt already, but thanks for the reminder.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [intllib]

by kaeza » Tue Jan 24, 2017 03:30

Sort of important update!

Intllib now supports using gettext message catalogs for translation.

The old conf-like interface is still available. You will need to change some stuff to support the new features. Please check out the docs for details.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

User avatar
burli
Member
 
Posts: 1313
Joined: Fri Apr 10, 2015 13:18

Re: [Mod] Internationalization Library [intllib]

by burli » Wed Mar 08, 2017 07:29

Is there somewhere a tutorial how to use intllib? I try to add it, but it doesn't work. And if I use Getter I get this message

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
WARNING[Main]: intllib.Getter is deprecated.Please use intllib.make_gettext_pair instead.


I want to use and support this

Edit: It's working now. And I just replaced Getter with make_gettext_pair
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

Re: [Mod] Internationalization Library [intllib]

by kaeza » Wed Mar 08, 2017 07:55

burli wrote:Is there somewhere a tutorial how to use intllib? I try to add it, but it doesn't work. And if I use Getter I get this message

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
WARNING[Main]: intllib.Getter is deprecated.Please use intllib.make_gettext_pair instead.


I want to use and support this

Edit: It's working now. And I just replaced Getter with make_gettext_pair

There's some docs in doc/developer.md. If you have any doubts, feel free to ask.

EDIT: If this error is not from your own mod, kindly ask the mod developer to update. The warning can be safely ignored.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Previous

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 14 guests

cron