#9112 closed enhancement (fixed)
Use gettext's contexts and extracted comments instead of our pipe syntax
Reported by: | nbachiyski | Owned by: | nbachiyski |
---|---|---|---|
Milestone: | 2.8 | Priority: | normal |
Severity: | minor | Version: | 2.7 |
Component: | I18N | Keywords: | has-patch |
Focuses: | Cc: |
Description
Our current (#3687) functionality for disambiguating and adding descriptions to translated strings has some flaws:
- We are using the same syntax (the pipe) for both disambiguating and adding descriptions
- It screws translation memories, because
Approved|main page
andApproved|adjective
are different strings for them - Translations get confused and often don't get that the text after | is a description or context
Instead, the recent gettext versions provide the following functionality:
- Contexts, which are part of the PO syntax:
msgctxt "context" msgid "term" msgstr "translation"
xgettext supports it and most translation tools too. poEdit works correctly with them, but still doesn't show the context anywhere.
- Extracted comments. If there is a comment directly preceding the gettext call, starting with, let's say
translators
, it is inserted as a comment in the PO file./* translators, see http://php.net/date */ $date = date(__('d.m.Y'));
becomes:
#. translators, see http://php.net/date msgid "d.m.Y" msgstr ""
These comments are shown by all translation software.
Attachments (5)
Change History (22)
#3
@
16 years ago
The current php-gettext library doesn't support contexts. I've got a rewritten, slightly more abstracted, cleaner and having some tests gettext library at http://svn.glotpress.org/trunk/pomo/
I will send a patch soon.
#4
@
16 years ago
- Keywords has-patch added
Here is a patch, which switches from current php-gettext to the GlotPress one. It expects the new library files to be in wp-includes/pomo
. In the beginning we can add it as an external and then we can trim it just to the needed files.
wp-includes/gettext.php
and wp-includes/streams.php
aren't needed any more.
I named the new context functions _x
and _nx
. It resembles conteXt.
Note: the patch includes the deprecation part from #9111.
#6
@
16 years ago
Went ahead and added pomo as a real directory instead of an external since switching from an external to a directory always seems to cause grief. We'll just have to keep it in sync.
#7
@
16 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Here is the first patch, which adds some _x()
calls and uses extracted comments like translators:
instead of _c()
.
#9
@
16 years ago
Next round of _x and comments. Role names caused some trouble, because they are kept in DB and currently their values have the |Role name suffix.
#11
@
16 years ago
The last patch of the series, a little bit larger than the previous ones.
Fixes several other minor problems:
- adds a lot of translator comments
- noop functions don't need to have similar interface to the standard gettext functions, so I got rid of the dummy args
- feed_links had separator spelled as seperator and a typo in one of the indices
- _x didn't have a dummy entry in the script/style loadign scrits
There is already support for this in the POT generating tools in http://svn.automattic.com/wordpress-i18n/tools/trunk/