Closed bradyvercher closed 9 years ago
This would likely require building a list of all translation functions and the index of their text domain arguments. The list should be readily available since it's typically used in Poedit headers.
Pulled from my grunt-checktextdomain config:
'__:1,2d',
'_e:1,2d',
'_x:1,2c,3d',
'_ex:1,2c,3d',
'_n:1,2,4d',
'_nx:1,2,4c,5d',
'_n_noop:1,2,3d',
'_nx_noop:1,2,3c,4d',
'esc_attr__:1,2d',
'esc_html__:1,2d',
'esc_attr_e:1,2d',
'esc_html_e:1,2d',
'esc_attr_x:1,2c,3d',
'esc_html_x:1,2c,3d'
Pulled from my makepot config:
__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;
The use of *d to indicate the position of the domain is not part of the gettext standard - it's something unique to grunt-checktextdomain, but it helps to clarify which number the text domain arg is for each function (the last one).
The *c is the position of the context description argument.
I spent some time in May going through to get this data, and came to the conclusion that most plugins and themes had been doing it wrong, since they had apparently just been blindly copying each other. The author of POEdit, @vslavik, kindly clarified my concerns.
I've run this against several projects and it looks like it's working well. Any issues can be addressed in separate tickets.
Per @GaryJones in #22:
This would likely require building a list of all translation functions and the index of their text domain arguments. The list should be readily available since it's typically used in Poedit headers.
Currently the
addtextdomain
task just does a blind match/replace/insert without being aware of the argument's position in the method definition, so that would need to be updated. Adding this kind of awareness to the tool would likely be valuable upstream as well.