CodeIgniter Forums

Full Version: Language strings support in localization
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I find it pretty hard to come up with unique language keys for every text strings. Its very useful if we have language string support in localization.

for example: lang('My text string');

Also its better we cant have alternative method for lang() method. like __(). its more cleaner and minimalitic.

Thanks.
You are not required to always put your translations in a language file. You can do it directly:
PHP Code:
lang('The {0} is {1}.', ['fox''here]); // echoes "The fox is here." 

For the
Code:
__()
alias, you can do that in your own implementation. But if you want others to make use of it, you can submit a PR in the github repo.
CI4 has a great online manual, you should always first look there and only afterwards flooding this forum.
https://codeigniter4.github.io/CodeIgnit...ation.html

I don't recommend and i don't support idea of "__()". That function has no general meaning, purpose, understanding what it stands for, will make more confusion than useability. That would be really bad to implement in CI4.
I'm with davis.lasis on this one.
lang() is only 4 letters. I don't see how __() is an improvement.
Also, double underscores an reserved for magic methods: https://www.php.net/manual/en/language.oop5.magic.php
I guess he saw that __() in other frameworks.