admin管理员组文章数量:1130349
I am getting this error?
Found a translation function that is missing a text-domain. Function _n
can this be fixed? how can the translation be done in this case?
if( count($value) < $field['min'] ) {
$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );
$valid = sprintf( $valid, $field['label'], $field['min'] );
}
UPDATE
The error is gone when $field['min'] was assigned to a variable. I am i doing it correct?
I am getting this error?
Found a translation function that is missing a text-domain. Function _n
can this be fixed? how can the translation be done in this case?
if( count($value) < $field['min'] ) {
$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );
$valid = sprintf( $valid, $field['label'], $field['min'] );
}
UPDATE
The error is gone when $field['min'] was assigned to a variable. I am i doing it correct?
1 Answer
Reset to default 1Your error (actually a warning) seems to come from the Theme Check plugin.
There's nothing wrong with the code you're showing above. 'acf' is your text domain. and the _n function takes four arguments as you've given it.
It strikes me that the Theme Check plugin is not very good at static analysis of function calls. I actually get a different warning with your code (possibly a later version) It seems it can't cope with array expressions like $field['min']. But of course WordPress/PHP will execute this just fine.
As you discovered yourself, assigning a variable gets rid of the warning. So doing something like the following is absolutely fine and seems to satisfy Theme Check's code scanner.
$n = $field['min'];
$valid = _n( '....', '....', $n, 'acf' );
$valid = sprintf( $valid, $field['label'], $n );
I am getting this error?
Found a translation function that is missing a text-domain. Function _n
can this be fixed? how can the translation be done in this case?
if( count($value) < $field['min'] ) {
$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );
$valid = sprintf( $valid, $field['label'], $field['min'] );
}
UPDATE
The error is gone when $field['min'] was assigned to a variable. I am i doing it correct?
I am getting this error?
Found a translation function that is missing a text-domain. Function _n
can this be fixed? how can the translation be done in this case?
if( count($value) < $field['min'] ) {
$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );
$valid = sprintf( $valid, $field['label'], $field['min'] );
}
UPDATE
The error is gone when $field['min'] was assigned to a variable. I am i doing it correct?
-
@Nicolai thanks!! error was exactly on this line
$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );sorry but i am not able to understand your answer, may be a little explanation if possible :) – user145078 Commented Nov 17, 2018 at 18:00 -
@Nicolai if i replace
$field['min']with$out, then it shows no error..$out = $field['min']..but not sure why it worked – user145078 Commented Nov 17, 2018 at 18:37 - @Nicolai may be bacause asper codex.wordpress/Function_Reference/_n , Important: Never do a calculation inside the sprintf() function – user145078 Commented Nov 17, 2018 at 19:29
1 Answer
Reset to default 1Your error (actually a warning) seems to come from the Theme Check plugin.
There's nothing wrong with the code you're showing above. 'acf' is your text domain. and the _n function takes four arguments as you've given it.
It strikes me that the Theme Check plugin is not very good at static analysis of function calls. I actually get a different warning with your code (possibly a later version) It seems it can't cope with array expressions like $field['min']. But of course WordPress/PHP will execute this just fine.
As you discovered yourself, assigning a variable gets rid of the warning. So doing something like the following is absolutely fine and seems to satisfy Theme Check's code scanner.
$n = $field['min'];
$valid = _n( '....', '....', $n, 'acf' );
$valid = sprintf( $valid, $field['label'], $n );
本文标签: Found a translation function that is missing a textdomain Function n
版权声明:本文标题:Found a translation function that is missing a text-domain. Function _n 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749170307a2326888.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


$valid = _n( '%s requires at least %s selection', '%s requires at least %s selections', $field['min'], 'acf' );sorry but i am not able to understand your answer, may be a little explanation if possible :) – user145078 Commented Nov 17, 2018 at 18:00$field['min']with$out, then it shows no error..$out = $field['min']..but not sure why it worked – user145078 Commented Nov 17, 2018 at 18:37