Skip to content

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

Description

@faizananwerali

"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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions