Welcome Guest, Not a member yet? Register   Sign In
Should the variable type for language keywords be static or const?
#1
Question 
(This post was last modified: 11-11-2024, 01:04 AM by kuzeyybora.)

Hello everyone,

I'm designing a multilingual project, and I created a folder named Constants with a file called LanguageKeys.php inside it. The structure looks like this:
PHP Code:
namespace App\Constants
class 
LanguageKeys 
  public const ALLOWED_LOCALS = ["tr""en""de"]; 
  public const SUCCESS 'RESPONSE_SUCCESSFULLY_MESSAGE'
  public const FAIL 'RESPONSE_UNSUCCESSFULLY_MESSAGE'
  public const CREATE_SUCCESS 'RESPONSE_CREATE_SUCCESSFULLY_MESSAGE'

Do you think these should stay as they are, or would it be better to make them
public static instead? These keys are saved to Redis from the database, and unless revalidation is done, the data is queried from Redis.
Do you have any suggestions or thoughts on this?
Reply
#2

KISS & DRY
Your repeating yourself.
PHP Code:
public array $supportedLocales = ['en''es''fr-FR']; 

Config files only uses strings for output.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB