Discussion:
Reusing WordPress translations of strings in a plugin
J.D. Grimes
2013-09-02 20:13:10 UTC
Permalink
I'm writing a plugin and of course I'm trying to do all of the I18n. I'm coming across some strings that need to be translatable, but that are already translated in WordPress core. What I mean is that, for example, the plugin has button with the text 'Save'. When I wrap this in the I18n functions, is there any reason that I should use the plugin's text domain instead of the default? Since that string will already be translated for WP, is there any reason to make folks translate it again for the plugin? I realize that in some cases, we might have to worry about different contexts, or the string eventually being removed from core. But with things like 'Save', 'Delete', 'Close', etc., is there really any reason to use the plugin's text domain, rather than calling the functions without it?

Thanks.

- J.D.
Otto
2013-09-02 20:26:57 UTC
Permalink
Yes, you should use your own text domain for these cases.. for exactly
the reasons you already mentioned.

1. Context matters. We use the word "Delete" in English, and it can
have different meanings based on context. In another language, the
context may make two uses of it into different words entirely.

2. Core can change, leaving your plugin untranslated with an update.
It's unlikely to change for something like "Save", but you never know.

3. Folks doing translations have tools (such as glotpress) to help
them. These make the job of translating somewhat easier, and having a
few extra duplicated strings is not as big a deal as you'd think.
Certainly not as big of a deal as them having to work around your
reuse of a string which may be in a different context.

-Otto
Post by J.D. Grimes
I'm writing a plugin and of course I'm trying to do all of the I18n. I'm coming across some strings that need to be translatable, but that are already translated in WordPress core. What I mean is that, for example, the plugin has button with the text 'Save'. When I wrap this in the I18n functions, is there any reason that I should use the plugin's text domain instead of the default? Since that string will already be translated for WP, is there any reason to make folks translate it again for the plugin? I realize that in some cases, we might have to worry about different contexts, or the string eventually being removed from core. But with things like 'Save', 'Delete', 'Close', etc., is there really any reason to use the plugin's text domain, rather than calling the functions without it?
Thanks.
- J.D.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
hamlet
2013-09-04 00:27:15 UTC
Permalink
Hello, I would like to change class in form element, when I called to
comment_form I can modify id but I cannot change class. Any idea?
Otto
2013-09-04 00:55:00 UTC
Permalink
Why would you need to change the class? You can already change the ID,
so reference it using that ID instead.

-Otto
Post by hamlet
Hello, I would like to change class in form element, when I called to
comment_form I can modify id but I cannot change class. Any idea?
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
hamlet
2013-09-04 01:08:16 UTC
Permalink
I cannot modify CSS in my project, therefore I must change class. I had
thinking to use jQuery, but I don't like this solution.

Thanks.
Post by Otto
Why would you need to change the class? You can already change the ID,
so reference it using that ID instead.
-Otto
Post by hamlet
Hello, I would like to change class in form element, when I called to
comment_form I can modify id but I cannot change class. Any idea?
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Otto
2013-09-04 01:37:30 UTC
Permalink
Why can you not modify the CSS? The correct way would be to change the
CSS to describe the look of the HTML, not the other way around.

-Otto
Post by hamlet
I cannot modify CSS in my project, therefore I must change class. I had
thinking to use jQuery, but I don't like this solution.
Thanks.
Post by Otto
Why would you need to change the class? You can already change the ID,
so reference it using that ID instead.
-Otto
Post by hamlet
Hello, I would like to change class in form element, when I called to
comment_form I can modify id but I cannot change class. Any idea?
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Ryan McCue
2013-09-04 02:14:01 UTC
Permalink
Post by Otto
Why can you not modify the CSS? The correct way would be to change the
CSS to describe the look of the HTML, not the other way around.
Seems a little ridiculous to not be able to change the class though. I'm
surprised that you can change the ID and not the class, I'd expect it to
be the other way around.

Keep in mind that if you're using an existing framework, it might be a
pain (without a CSS preprocessor at least) to style IDs rather than
classes. It's also a little kludgy.
--
Ryan McCue
<http://ryanmccue.info/>
Otto
2013-09-04 02:42:31 UTC
Permalink
Post by Ryan McCue
Seems a little ridiculous to not be able to change the class though. I'm
surprised that you can change the ID and not the class, I'd expect it to
be the other way around.
You can change the ID in case you're using a system by which you put
more than one comment form on the page (ala P2 and similar). The ID
must be unique, so you can change it to be so if needed.
Post by Ryan McCue
Keep in mind that if you're using an existing framework, it might be a
pain (without a CSS preprocessor at least) to style IDs rather than
classes. It's also a little kludgy.
If the framework doesn't let you address document elements by ID, then
I'd say that's a rather strange framework indeed. What is so hard
about using #comment-form instead of .comment-form?

If you're referring to a specific element, then ID is the correct way
to do that. If you just want to refer to it by class for some reason,
well, then .comment-form works just fine.

My question is, in what realistic situation should you be changing the
HTML in order to achieve a targeting improvement via CSS? Remember
that you have control over the ID of the element in question, so it's
not a matter of not being able to target it directly if desired. CSS
should be changed to achieve stylistic changes, not the other way
around.

-Otto
Daniel
2013-09-04 02:50:00 UTC
Permalink
One case is that want your wp site to match the rest of our website or
forum (phpbb comes to mind)
Post by Otto
Post by Ryan McCue
Seems a little ridiculous to not be able to change the class though. I'm
surprised that you can change the ID and not the class, I'd expect it to
be the other way around.
You can change the ID in case you're using a system by which you put
more than one comment form on the page (ala P2 and similar). The ID
must be unique, so you can change it to be so if needed.
Post by Ryan McCue
Keep in mind that if you're using an existing framework, it might be a
pain (without a CSS preprocessor at least) to style IDs rather than
classes. It's also a little kludgy.
If the framework doesn't let you address document elements by ID, then
I'd say that's a rather strange framework indeed. What is so hard
about using #comment-form instead of .comment-form?
If you're referring to a specific element, then ID is the correct way
to do that. If you just want to refer to it by class for some reason,
well, then .comment-form works just fine.
My question is, in what realistic situation should you be changing the
HTML in order to achieve a targeting improvement via CSS? Remember
that you have control over the ID of the element in question, so it's
not a matter of not being able to target it directly if desired. CSS
should be changed to achieve stylistic changes, not the other way
around.
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
--
Regards,
Daniel Fenn
Otto
2013-09-04 02:55:02 UTC
Permalink
Post by Daniel
One case is that want your wp site to match the rest of our website or
forum (phpbb comes to mind)
Okay, but in that case you would add rules to the CSS to add the
necessary styling to it look the same, or similar, to whatever you
want to make it look like. You wouldn't change the classes of the HTML
to fit some random CSS that was designed for something else entirely.
That isn't how CSS works.

-Otto
hamlet
2013-09-04 11:43:41 UTC
Permalink
My case is similar, I am using Bootstrap, therefore the original file
cannot be changed, I have my own file, but I should copy style from
Bootstrap file to my file, I don't like repeat (exactly)same code, It is
very dirty.
Post by Otto
Post by Daniel
One case is that want your wp site to match the rest of our website or
forum (phpbb comes to mind)
Okay, but in that case you would add rules to the CSS to add the
necessary styling to it look the same, or similar, to whatever you
want to make it look like. You wouldn't change the classes of the HTML
to fit some random CSS that was designed for something else entirely.
That isn't how CSS works.
-Otto
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Ryan McCue
2013-09-04 13:59:27 UTC
Permalink
Post by Otto
If the framework doesn't let you address document elements by ID, then
I'd say that's a rather strange framework indeed. What is so hard
about using #comment-form instead of .comment-form?
Because maybe my #comment-form is also a .section, and maybe a .large-form.

Easy enough with preprocessors (#comment-form { @extend .section;
@extend .large-form }), but not with normal CSS without duplicating all
the existing styles.

(Otherwise you end up with something like wp-admin's CSS, which is
frankly ridiculous.)
--
Ryan McCue
<http://ryanmccue.info/>
Loading...