Opened 8 years ago
Closed 10 months ago
#41257 closed defect (bug) (wontfix)
translate( null, "domain" ) returns translation of "0" rather than null
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | |
Component: | I18N | Keywords: | has-unit-tests close |
Focuses: | Cc: |
Description
This could be a case of garbage in = garbage out but I noticed that calling
translate( null, "domain" )
or translate( "", "domain" )
produces an unexpected result when
- the text domain for "domain" is loaded
- and it contains a translation for "0".
Expected output
null or null string
Actual output
translation of the "0"
string
Workaround
Don't call translate() this way.
Question
Could/should there be a unit test to confirm what should happen?
Attachments (1)
Change History (6)
#2
@
8 years ago
- Keywords has-unit-tests has-patch added
- Severity changed from normal to minor
@MaximeCulea Not sure what you mean by your first sentence.
I've added a unit test case that demonstrates the unexpected results, thereby confirming the current edge case behaviour.
If the logic in translate() is changed so that it returns different values then the test will fail.
Note: See
TracTickets for help on using
tickets.
I am wondering if
translate( null, "domain" )
could solve here your problem.Because it seems legit for me that if the first arg is empty ( null, zero, empty string, etc), the translation "fails".
Moreover, I see that first arg is specified like this :