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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:34:01+00:00 2026-06-15T19:34:01+00:00

I am currently working on a API allowing users to get some event messages

  • 0

I am currently working on a API allowing users to get some event messages on their devices. Users call my API specifying me their preferred locale (for instance fr_FR).

On the back-office, administrators can choose the languages they want to support. Let’s assume they choose English and Chinese. So, they do not support French language.

I am using the Propel I18N behavior to deal with all the translations. In my requests, I am currently doing:

SystemMessageQuery::create()
    ->joinWithI18N('fr_FR')
    ->findOne();

It works correctly if I specify an existing locale. Yet, if the translation is not available, it returns null. Sounds logical.

My question is: can I fallback the user on a default locale (in this case, en_US) if the provided locale is not planned by an administrator? If yes, how can I proceed?

I thought to send a prior request to check if the locale exists. But I do not think it is a good way for performances reasons (especially for an API).

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-15T19:34:02+00:00Added an answer on June 15, 2026 at 7:34 pm

    Finally, I used the following code:

    public function setLocale($locale = 'en_US', $fallbackEnabled = false)
    {
        if($fallbackEnabled) {
    
            $localeExists = SystemMessageI18nQuery::create()
                ->filterByLocale($locale)
                ->filterById($this->getId())
                ->count();
    
            if(!$localeExists) {
                $locale = SystemMessageI18nQuery::create()
                    ->filterById($this->getId())
                    ->select('locale')
                    ->findOne();
            }
    
        }
    
        parent::setLocale($locale);
    }
    

    It is not the best solution for performance reasons, but it is functionnal.

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

Sidebar

Related Questions

I am currently working on the HTML5 File API, and I need to get
We have (currently) working projects that use Javascript API to get the Facebook session
I am currently working with FileMaker and their PHP API, and I have to
Im currently working with an API which requires we send our collection details in
I am currently working with an IPhone API which consist of about 40 pages
I am currently working on MVC4 SinglePage Application. I have a Web Api method
Currently working with converting SQLException error messages into messages that are more useful for
Currently working on a VBScript to automate some of the dirty PST ingestion work
We're currently working on an API that will be consumed by a variety of
I'm currently working on a script that'll be working with Youtubes API. I'm still

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.