CodeIgniter4
CodeIgniter4 copied to clipboard
Comment about consistency in Language strings
Just want to comment on the use of {0}
in the strings:
there are multiple ways of showing for example filenames in the messages:
"{0}"
, ({0})
, `{0}`
or simply without quotes or parenthesis {0}
Should maybe be standardized to one format?
I think this should be discussed in the main repository. So that if ever there will be changes there, those will just be cascaded here.
(Sorry, didn't see it was moved)
Should maybe be standardized to one format?
I would like to if possible.
@tangix if you would like to take a first pass at that we would gratefully review your Pull Request!
@tangix if you would like to take a first pass at that we would gratefully review your Pull Request!
I can work on that. Unfortunately I think this change will break backward compatibility when tests checking the error message will start to fail, please advise.
Personally I prefer "{0}"
where the filename/value is in the text and simply {0}
where it is obvious what the value signifies.
For example:
'Command "{0}" not found.'
'"{0}" class expected cookies array to be instances of "{1}" but got "{2}" at index {3}.'
and when separated by colon:
'Error while creating file: {0}'
'Failed to authenticate username. Error: {0}'
Also, I think errors should be written like this: 'Failed to parse json string, error: "{0}".'
should be written 'Failed to parse json string. Error: {0}.'
I'm good with all those opinions. I think the consistency is more important than the particular syntax (though I would probably do pretty much as you have suggested).
Language files and contents are intentionally internal, so no concerns about breaking changes. If a test is verifying a language response it should be using the function, not the text directly:
// this:
$this->assertSame(lang('Foo.bar', ['bam']), $result);
// not this:
$this->assertSame('Foo bar had a "bam"', $result);
I think if the value (may) contains a space, it is better to quote with "
.
Error while creating file: abc def.txt
Error while creating file: "abc def.txt"
Error while creating file: abc def.txt
Error while creating file: " abc def.txt"
Personally I prefer "{0}" where the filename/value is in the text and simply {0} where it is obvious what the value signifies. Also, I think errors should be written like this: 'Failed to parse json string, error: "{0}".' should be written 'Failed to parse json string. Error: {0}.'
I'm both in favor.
Closed by https://github.com/codeigniter4/CodeIgniter4/pull/6474
👏