#10286 closed defect (bug) (fixed)
load_textdomain: Incorrect PHPDoc and possibly unwanted merging behaviour
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 2.8.1 | Priority: | normal |
Severity: | normal | Version: | 2.8 |
Component: | I18N | Keywords: | has-patch |
Focuses: | Cc: |
Description
The PHPDoc for load_textdomain in wp-includes/l10n.php says that loading a file for an already existing domain will fail. This was correct at the time when the comment was written, but the function has been changed after that and now merges the translations.
However, if a string has been translated in both the already loaded and the new file, the existing translation will be used. In my opinion, it should be the other way round. If I'm satisfied with the translations in general, but want to change just a few of the strings, I have to change the translation file (which would be necessary again for every new version). It would be easier to create a new file with only the changed translations. However, the default domain is loaded at the very beginning, so I can't simply use load_textdomain('default', $myfile);
The attached patch changes this behaviour so that new translations will overwrite existing ones. The PHPDoc should then be changed to reflect the actual behaviour in case of an existing domain. Maybe the @uses references are outdated as well, I'm not sure.
Attachments (2)
Change History (9)
#1
@
16 years ago
- Keywords needs-doc removed
The current behavior is mostly inspired by bbPress integration. Although the use case of replacing translations with custom ones seems logical, I haven't seen anybody try to do that.
Updating the docs seems enough for now.
Attched is a patch, which updates the docs and adds proper return values for load_textdomain()
.
#2
@
16 years ago
- Cc wordpress@… added
I actually thought about replacing some translations depending on the theme. Well ok, as this call to load_textdomain() would happen in my code then (not in the core), I can work around this.
The patch looks good, just one thought: load_plugin_textdomain()
etc. call load_textdomain()
, maybe these should pass the return value on?
New translations overwrite existing ones