Am I breaking any “php good practice” in the following php array which deals with 3 (human) languages?

后端 未结 6 1684
执笔经年
执笔经年 2021-01-03 10:47

This is the most optimal way of dealing with a multilingual website I can think of, right now (not sure) which doesn\'t involve gettext, zend_translate or any php plugin or

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-03 11:24

    Looks all right to me also, but:

    Seems that you have localization for multiple modules/sites, so why not break it down to multidimensional array?

    $localization = array(
      'module' => (object)array(
        'heading' => 'oh, no!',
        'perex'   => 'oh, yes!'
      )
    );
    

    I personally like to creat stdClass out of arrays with

    $localization = (object)$localization;
    

    so you can use

    $localization->module->heading;
    

    :) my 2 cents

提交回复
热议问题