Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3940070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:22:27+00:00 2026-05-20T00:22:27+00:00

Well, here’s a great question that has always disturbed me. Introduction I’m developing a

  • 0

Well, here’s a great question that has always disturbed me.

Introduction

I’m developing a web application that should be multi-language and customizable.
So i developed a registry-class (that will group my internal configurations) and a language class that will take care of getting the right language file (based on the browser language) and get the language string i need.

Let’s get deeper

Let’s talk about the use of this classes

# config.reg.php
self::set('configuration-name');
# whatever-file.php
reg::get('configuration-name');

The same piece of code is used for the language class which will have a

# it.lang.php
self::set('duck-you', 'Daffanculo');
# en.lang.php
self::set('duck-you', 'Duck you');
# whatever-file.php
lang::get('duck-you');

The real matter

Ok, now. I’m always pretty much d*cked while choosing the right name for the configurations and for the language indexes, and I always end up with something like:

self::set('that-error-message-that-appear-when-a-user-is-not-logged-in');

Or:

self::set('your-login-action-has-encountered-a-problem-please-get-back-later');

for languages, and:

self::set('that-cookie-name-used-in-X-file');

for configurations.
…wich is not that great.

Final question

So i was wondering, are there any names conventions that could help me getting trough this and move on?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:22:28+00:00Added an answer on May 20, 2026 at 12:22 am

    for starters your language values should not be encapsulated in your registry object.

    your registry object should only contain objects such as Session, Language, Input, output etc, so your static class should be build like so:

    abstract class Registry
    {
        public static function get($key)
        {
        }
    
        public static function set($key,$object)
        {
        }
    }
    

    then you would insert your objects into the Registry like so:

    Registry::set("Language", new Language());
    

    You should then use your language class to fetch your language files:

    $Language = Registry::get("Language");
    $Message = $Language->get("YourMessageKey");
    

    in regards to naming conventions I would advice you to use all lowercase, and underscores only (this is for clarity)

    so the following line:

    that-error-message-that-appear-when-a-user-is-not-logged-in
    

    would become

    that_error_message_that_appear_when_a_user_is_not_logged_in
    

    but this is way to long and pointless, what you should do is have your language multi-dimensional so that the error messages are contained within the error context.

    $Language->errors("user_not_logged_in");
    

    which becomes much more readable and has better performance because you would split your context’s up into separate files like so

    /locale/en/primary.php | loaded by default
    /locale/en/errors.php
    /locale/en/menu.php
    /locale/en/user.php
    

    Each would only be loaded when called, for example:

    $Language->user("welcome_new_user");
    /*         ^                      */
    

    In your language class create a call method to be able to do this kind of selecting:

     public function __call($context,$params)
     {
         if(!$this->contextLoader($context))
         {
             $this->loadContext($context)
         }
         return $this->languages[$this->lid][$context][$params[0]];
     }
    

    This will make things much more manageable.

    Note:

    Wash your dirty mouth out!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's one from the No question's too dumb department: Well, as the subject says:
this is my first question here so I hope I can articulate it well
Object-relational mapping has been well discussed, including on here. I have experience with a
Well here's a rather stupid question. Is Visual C++ JUST an IDE?? Or is
OK, I have my site going pretty well here: http://www.marioplanet.com But I've realized that
I have a code that works well here: #!/usr/bin/perl use strict; use warnings; use
Well here's my problem I have three tables; regions, countries, states. Countries can be
Well, here's a nice obscure one. I'm trying to compile the latest open transport
Well, this is my first post here and really enjoying the site. I have
Well I tried to figure out is this possible in any way. Here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.