Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated 'intllib' function: #382

Closed
wants to merge 1 commit into from

Conversation

AntumDeluge
Copy link
Contributor

  • 'intllib.Getter' with 'intllib'make_gettext_pair' if available,
    otherwise use deprecated function.

@@ -5,7 +5,7 @@ local technic = rawget(_G, "technic") or {}
technic.concrete_posts = {}

-- Boilerplate to support localized strings if intllib mod is installed.
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
local S = rawget(_G, "intllib") and intllib.make_gettext_pair() or intllib.Getter() or function(s) return s end
Copy link
Contributor

@numberZero numberZero Jul 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rawget(_G, "intllib") and (intllib.make_gettext_pair() or intllib.Getter()) or function(s) return s end
or
minetest.global_exists("intllib") and (intllib.make_gettext_pair() or intllib.Getter()) or function(s) return s end
or better something not that complicated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh jeez, I can't believe I forgot the braces. 🙄

@AntumDeluge
Copy link
Contributor Author

How is that?

@AntumDeluge
Copy link
Contributor Author

Would it be better to replace technic.getter = intllib.Getter() with technic.getter = (intllib.make_gettext_pair() or intllib.Getter()) instead of using the condition checks?

@numberZero
Copy link
Contributor

Would it be better to replace technic.getter = intllib.Getter() with technic.getter = (intllib.make_gettext_pair() or intllib.Getter()) instead of using the condition checks?

@AntumDeluge no, conditional statements are better. What I suggested is wrong: braces per se can’t help if make_gettext_pair is not defined, and checking its existence as well makes the statement insanely long.

@@ -5,7 +5,7 @@ local technic = rawget(_G, "technic") or {}
technic.concrete_posts = {}

-- Boilerplate to support localized strings if intllib mod is installed.
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
local S = rawget(_G, "intllib") and (intllib.make_gettext_pair() or intllib.Getter()) or function(s) return s end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not do what it should (see numberZero's comment). Just use intllib.make_gettext_pair() everywhere (exists for an entire year already). Do not support legacy code and let them update their outdated mods.

@@ -7,7 +7,11 @@
local S
if (minetest.get_modpath("intllib")) then
dofile(minetest.get_modpath("intllib").."/intllib.lua")
S = intllib.Getter(minetest.get_current_modname())
if (intllib.make_gettext_pair) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

S = technic.getter or am I missing something?

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@AntumDeluge
Copy link
Contributor Author

It's been a while. I hope that is what you were looking for. Let me know if I misunderstood anything please.

Copy link
Member

@SmallJoker SmallJoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SmallJoker
Copy link
Member

Closing in favour of #529

@SmallJoker SmallJoker closed this Mar 19, 2020
@AntumDeluge AntumDeluge deleted the intllib_update branch July 15, 2021 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants