Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translation function 'lang' does not work as described #3822

Closed
vonboth opened this issue Oct 27, 2020 · 3 comments · Fixed by #3849
Closed

Translation function 'lang' does not work as described #3822

vonboth opened this issue Oct 27, 2020 · 3 comments · Fixed by #3849
Labels
bug Verified issues on the current code behavior or pull requests that will fix them documentation Pull requests for documentation only

Comments

@vonboth
Copy link

vonboth commented Oct 27, 2020

In the documentation you are describing the lang function to work this way:

// Displays "£7.41"
echo lang('{price, number, currency}', ['price' => 7.41], 'en-GB');

However this doesn't work in the current release (4.0.4).

It just echos the string: {price, number, currency}

If I comment out the lines 140 - 143 inside the file framework/system/Language/Language.php

// ignore requests with no file specified
		/*if (! strpos($line, '.'))
		{
			return $line;
		}*/

it works as described and the output is: £7.41

@paulbalandan
Copy link
Member

I believe this is more of a documentation issue than a bug in the code. The lang function is intended to work with language strings inside files which are loaded by the function.

@paulbalandan paulbalandan added the documentation Pull requests for documentation only label Nov 2, 2020
@vonboth
Copy link
Author

vonboth commented Nov 2, 2020

Is that so?
It would be much more comfortable (and makes more sense to me) if it would work as described in the documentation and not in the way that every string has to be a language file.

However either this or that needs a revision.

@paulbalandan
Copy link
Member

Per code, the parsing seems to support only file-based language strings. But you are right. The example in the documentation is most appropriate for single uses.

Any thoughts, @MGatner , @michalsn , @samsonasik ?

@paulbalandan paulbalandan added the bug Verified issues on the current code behavior or pull requests that will fix them label Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them documentation Pull requests for documentation only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants