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

[Feature] get all message from a category #3

Closed
ziaratban opened this issue Nov 19, 2018 · 8 comments
Closed

[Feature] get all message from a category #3

ziaratban opened this issue Nov 19, 2018 · 8 comments

Comments

@ziaratban
Copy link

Q A
Yii version 2.0.12?

Hi
i think this feature is need for big project that using internationalization(I18N).
but where is it used?
this is used in interaction between server I18N and client project like javascript.
i prepared a sample example.

Yii messages file in TreeView category

return [
    'Hello' => 'سلام',
    'Good' => 'خوب',
];

in javascript

var obj = new MyTreeViewClass();
obj->languages = '<?=yii::t('TreeView',null)?>';

in above js example i use null parameter for t method, because null means get all message from TreeView category.

also see
how i can get a category message in yii ?

@samdark samdark self-assigned this Jun 21, 2017
@viktorprogger
Copy link
Contributor

This issue is the same as #95

@samdark samdark transferred this issue from yiisoft/yii-core Jun 27, 2019
@samdark samdark transferred this issue from yiisoft/i18n Feb 6, 2020
@samdark
Copy link
Member

samdark commented Dec 24, 2020

That is hardly possible because choosing a message may consider parameters. That is true, for example, for gettext plurals.

@ziaratban
Copy link
Author

when we sent all the messages into client, therefore that parameters must be managed by the client(js).

@samdark
Copy link
Member

samdark commented Dec 25, 2020

We can't get the message not knowing parameters when using gettext.

@samdark samdark reopened this Dec 25, 2020
@ziaratban
Copy link
Author

@samdark you right!
but my goals of this issue is using the php array instead of the gettext.
php array is powerful and flexible.

@samdark
Copy link
Member

samdark commented Dec 25, 2020

You can get the array directly, I guess. Just via require 'messages.php';.

@ziaratban
Copy link
Author

yes. seems this feature is not supported by yii2 because the yii2 uses gettext and maybe in future yii2 using array instead of the gettext.

thanks.

@samdark
Copy link
Member

samdark commented Dec 25, 2020

Yii 2 and Yii 3 can use gettext or PHP. The issue is that the interface is common so you can use one implementation or another without changing actual code. Therefore, the interface can not contain methods that can't work in one of the implementations.

Anyway, that seems to be specific task dependent on message storage format. Can't be implemented in a generic way.

@samdark samdark closed this as completed Dec 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants