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

Return value of lang() must be of the type string, array returned #2075

Closed
faizananwerali opened this issue Jun 25, 2019 · 1 comment · Fixed by #2261
Closed

Return value of lang() must be of the type string, array returned #2075

faizananwerali opened this issue Jun 25, 2019 · 1 comment · Fixed by #2261

Comments

@faizananwerali
Copy link

"Return value of lang() must be of the type string, array returned" this is the error I got when I was trying to access language with list array as per example https://codeigniter4.github.io/CodeIgniter4/outgoing/localization.html#nested-arrays

Language/en/Login.php

`return [
    'list' => [
        // Heading
        'heading_title'         => 'User',

        // Text
        'text_success'          => 'Success: You have modified attributes!',
        'text_list'             => 'User List',
        'text_add'              => 'Add User',
        'text_edit'             => 'Edit User',

        // Column
        'column_name'            => 'User Name',
        'column_attribute_group' => 'User Group',
        'column_sort_order'      => 'Sort Order',
        'column_action'          => 'Action',

        // Entry
        'entry_name'             => 'User Name',
        'entry_attribute_group'  => 'User Group',
        'entry_sort_order'       => 'Sort Order',

        // Error
        'error_permission'       => 'Warning: You do not have permission to modify attributes!',
        'error_attribute_group'  => 'User Group Required!',
        'error_name'             => 'User Name must be between 1 and 64 characters!',
        'error_product'          => 'Warning: This attribute cannot be deleted as it is currently assigned to %s products!',
    ]
];`

I'm trying access all in one go to avoid call lang function again and again.

In Controller

  $data['lang_list_array'] = lang('Login.list', [], 'en');

The Result I got is "Return value of lang() must be of the type string, array returned". Is it a bug or error on my side, what mistake did I made?

I also tried this from documentation but it also didn't work

return [
    'list' => [
        'Apples',
        'Bananas',
        'Grapes',
        'Lemons',
        'Oranges',
        'Strawberries'
    ]
];

CodeIgniter 4 version
v4.0.0-beta-3

Context

  • OS: Windows 10
  • Web server Apache 2.4.37
  • PHP version 7.2.14
@jim-parry
Copy link
Contributor

lang() can indeed return an array. Examples in the website2 repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants