CodeIgniter Forums
Language strings support in localization - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Language strings support in localization (/showthread.php?tid=78199)



Language strings support in localization - MrWhite - 12-13-2020

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.


RE: Language strings support in localization - paulbalandan - 12-16-2020

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.


RE: Language strings support in localization - davis.lasis - 12-16-2020

CI4 has a great online manual, you should always first look there and only afterwards flooding this forum.
https://codeigniter4.github.io/CodeIgniter4/outgoing/localization.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.


RE: Language strings support in localization - includebeer - 12-16-2020

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


RE: Language strings support in localization - paulbalandan - 12-17-2020

I guess he saw that __() in other frameworks.