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 8175121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:39:19+00:00 2026-06-06T22:39:19+00:00

Nota: this is not a duplicate of Translating PHP date() for Multilingual Site .

  • 0

Nota: this is not a duplicate of Translating PHP date() for Multilingual Site . I’ve read it!

I’m sorry, I first have to explain how my framework works, so you can understand precisely where my problem is:

Here’s how my Php code works (rough principles). Let’s use for an example someone who wants to see the URL http://myweb.com/valid.php:

  • in the file valid.php the code include the right classes definition then create one object and call the function display() which displays the page.
  • in the file valid.php, when the object is created, it analyses the host, and in the host there’s the language (http://us.myweb.com/, http://cn.myweb.com/, http://fr.myweb.com/…) and the default language (if none found) is english
  • then I load a cached Php file where the are the translations. This is a translation object, that I’m calling $t for short
  • and from now on, whenever I want a translation, I just do things like $t->get('my_string').

Let’s take an example with 2 languages file:

  • 2 languages files: cache.us.php and cache.fr.php
  • in cache.us.php you have a line like this: $thanks_for_the_fish = "Thanks for the fish".
  • in cache.fr.php you have a line like this: $thanks_for_the_fish = "Merci pour le poisson".
  • I construct my page, include the right language file then call $t->get('thanks_for_the_fish') and it’s translated.

Now my problem comes with date formatting.
With short date format it’s not a problem:

  • in cache.us.php: $short_date_format = "m/d/Y, H:i".
  • in cache.fr.php: $short_date_format = "d/m/Y à H:i".

But with long date format, I’m just working on french and I begun with something like:

  • in cache.fr.php: $long_date_format = "%s, %d %s %d".
  • then all the days: $sunday = "dimanche", $monday = "lundi" and so on
  • then in my translation code:

Something like this (read carefully the comment in the code, my question is in it!):

static private $_TabStrDaysOfWeek = array(
    0 => 'sunday',
    1 => 'monday',
    ...,
    6 => 'saturday'
);
public function translateDate($date_time)
{
    $long_day = $this->tr->get(
        $this->_TabStrDaysOfWeek[ $date_time->format('w') ]
    );
    /*

    here's where I'm stuck:
    what could be the code to be able to display:
    - english:
      Monday, 1st September 2006
      Tuesday, 2nd September 2006
      Wednesday, 3rd September 2006
      Thursday, 4th September 2006

    - french:
      Lundi, 1 septembre 2006
      Mardi, 2 septembre 2006
      Mercredi, 3 septembre 2006
      Jeudi, 4 septembre 2006

    - arabian!!:
      1 - Don't know
      2 - Don't know
      3 - Don't know
      4 - Don't know
    */
}

… And I said arabian because I’ll need it sooner or later, same for Mandarin Chinese.
All my other translation problems are solved but this one!!

Any idea?

  • 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-06-06T22:39:21+00:00Added an answer on June 6, 2026 at 10:39 pm

    For internationalization tasks, I’d strongly recommend using the PHP intl extension. It contains several classes for common internationalization tasks such as date/time formatting, number formatting, string transliteration and more. Specifically, the IntlDateFormatter class
    is able to format (and parse) a datetime for any available locale.

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

Sidebar

Related Questions

I hope this post is not a duplicate one. Let me explain: I have
First off, this is NOT a duplicate of: Turn a C string with NULL
I hope this is not a duplicate of a question, but I have three
First of all: this is not a duplicate of Delphi and SAPI . I
First of all, this is not a duplicate of Enums in Ruby :) The
This is not a duplicate of this question . I have to serialize the
This is not a duplicate post, i just done research but not helping. First,
I hope this is not a duplicate, I've read a number of related questions
First this is not a duplicate questions. I've looked through some similar problem and
This is NOT a duplicate question, and the problem is driving me crazy. I

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.