-
Notifications
You must be signed in to change notification settings - Fork 28
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
Isn't Np_
missing?
#108
Comments
OK. Let's add it! This may work: diff --git a/lib/gettext.rb b/lib/gettext.rb
index f8b8563..9d8214c 100644
--- a/lib/gettext.rb
+++ b/lib/gettext.rb
@@ -243,6 +243,11 @@ module GetText
[msgid, msgid_plural]
end
+ # TODO
+ def Np_(msgctxt, msgid)
+ [msgctxt, msgid]
+ end
+
# Sets charset(String) such as "euc-jp", "sjis", "CP932", "utf-8", ...
# You shouldn't use this in your own Libraries.
# * charset: an output_charset
diff --git a/lib/gettext/tools/parser/ruby.rb b/lib/gettext/tools/parser/ruby.rb
index 8d563a8..0b3e472 100644
--- a/lib/gettext/tools/parser/ruby.rb
+++ b/lib/gettext/tools/parser/ruby.rb
@@ -21,7 +21,7 @@ module GetText
class POExtractor < Ripper::Filter
ID = ["gettext", "_", "N_", "sgettext", "s_"]
PLURAL_ID = ["ngettext", "n_", "Nn_", "ns_", "nsgettext"]
- MSGCTXT_ID = ["pgettext", "p_"]
+ MSGCTXT_ID = ["pgettext", "p_", "Np_"]
MSGCTXT_PLURAL_ID = ["npgettext", "np_"]
attr_accessor :use_comment
@@ -95,7 +95,7 @@ module GetText
def process_on_const(token, po)
case token
- when "N_", "Nn_"
+ when "N_", "Nn_", "Np_"
# TODO: Check the next token is :on_lparen
process_on_ident(token, po)
else And we need to add tests for it. |
Hi! Thanks for the fast reaction! Wrt But then the question is how to resolve a Cheers! |
Ah, you're right. We should "just return the msgid" because def Np_(msgctxt, msgid)
msgid
end |
Hi, I took some more time to think about that. When using str = N_("foo|bar")
# str == "foo|bar", *not* "bar"
...
s_(str) And it is absolutely critical that the context is preserved. I think it should work just the same for str = Np_("foo", "bar")
...
p_(str) Yes, at the end I'm using
So I conclude that we need another function, that behaves like this: def pp_(s) = p_(*s.split("\004", 2)) Instead of splitting, if we can query the catalogue, it could be something like def pp_(s) = get_msgstr(s) || s.split("\004", 2)[1] where Finally, instead of naming this function Do I make sense? Cheers! |
Thanks for considering API! How about using def Np_(msgctxt, msgid)
[msgctxt, msgid]
end
def p_(msgctxt, msgid=nil)
msgctxt, msgid = msgctxt if msgctxt.is_a?(Array) and msgid.nil?
TextDomainManager.translate_singular_message(self, msgid, seperator)
end We can write the following with this API: message = Np_("foo", "bar")
...
p_(message) |
Hi,
I'm using
p_
translations. But I can't find the equivalent forN_
to tag-but-not-translate contextual messages.Am I missing something?
Sure enough I can define one that just returns the msgid. But the parsers don't look at it.
Thanks in advance!
The text was updated successfully, but these errors were encountered: