#10527 closed enhancement (fixed)
load_textdomain() merges even if not needed.
| Reported by: | hakre | Owned by: | nbachiyski |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | I18N | Version: | 2.8.1 |
| Severity: | normal | Keywords: | has-patch tested 2nd-opinion |
| Cc: | Focuses: |
Description
About 4 weeks ago in #10286 with [11680] & [11681] merging of textdomains have been introduced in load_textdomain(). That generally is a good feature, but I would like to see it optional to not merge textdomains over and over again.
for example with one of my co-maintained plugin we load the translation in an important object as well as in the admin panel. doing the merge now in the admin panel would not be necessary.
Therefore I suggest to add an optional parameter that flags if a merge is wanted / needed.
Attachments (4)
Change History (19)
#2
@
17 years ago
- Keywords 2nd-opinion added
- Milestone 2.8.3 → 2.9
- Type defect (bug) → enhancement
attachment 10527.patch added
- Typo in comments: "textdomain in nemory."
- The commits you refer to, Change nothing other than spacing, and comments, as well as adding a error-condition handler..
- Merging is the current default, So shouldn't the merge param be true by default? - It was after all, apparently chosen to merge by default.
This is really an enhancement, setting as such.
Milestone: Current trunk (2.9) for enhancements with patch.
#3
@
17 years ago
See for merging: #7376 (closed enhancement: fixed), Opened 12 months ago, Allow merging of similarly named text domains
#4
@
17 years ago
Then it should default true for textdomain and default false for plugin. I must change the patch later on, need to go now.
#5
@
17 years ago
Updated the patch. Defaults to true now for load_textdomain(). Fixed the typo in comments as well as taking care of line-length in the docblock comments and stricter writing according to the wordpress coding standards.
#6
@
17 years ago
Another Idea is to have an additional function called load_plug_textdomain_once() and load_textdomain_once(). But that would help to keep the existing function signatures untouched but it would mean more code.
#7
@
17 years ago
For those who are looking for a workaround for their plugins, this is a tested piece of code that has a shortcomming in using the global directly but it's working. Can be used in a plugin's function or class:
global $l10n;
$domain = 'pluginstextdomain';
if (!isset( $l10n[$domain] ))
{
load_plugin_textdomain($domain, false, 'path_to/languages');
}
#8
@
17 years ago
maybe the API should be extended having a is_textdomain_loaded() function? just in case the whole patch is not fitting.
#11
@
17 years ago
- Milestone Future Release → 3.0
The case of plugins with so many strings that the merge becomes a problem is extremely rare. I don't think it warrants an extra argument for these functions.
However, it makes sense to have an API call for checking whether a domain is empty. This way if it very important to you, you can check if your translation is already loaded.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Uploaded a patch.
It is tested, I applied the changes to the core sourcecode and then used a plugin to load a plugin textdomain. that plugin textdomain is loaded then only once, once it has been loaded it is not automatically merged. Setting the optional $merge parameter to true then gets it loaded & merged then.