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

  • Home
  • SEARCH
  • 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 6570247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:43:55+00:00 2026-05-25T14:43:55+00:00

We can config in Magento to set locale language and using function $this->__(string $test)

  • 0

We can config in Magento to set locale language and using function $this->__(string $test) to translate.

How about this feature but for javascript? For example, when I use validation.js and when getting some errors it will show the message with the locale language which I set.

The validation.js file is located at: src/js/prototype/prototype.js

In inside the file we will see something:

Validation.addAllThese([
    ['validate-select', 'Please select an option.', function(v) {
                return ((v != "none") && (v != null) && (v.length != 0));
            }],
    ['required-entry', 'This is a required field.', function(v) {
                return !Validation.get('IsEmpty').test(v);
            }],
    ['validate-number', 'Please enter a valid number in this field.', function(v) {
                return Validation.get('IsEmpty').test(v) || (!isNaN(parseNumber(v)) && !/^\s+$/.test(parseNumber(v)));
            }]
]

So, how could I translate the messages This is a required field.,Please select an option.?

  • 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-25T14:43:55+00:00Added an answer on May 25, 2026 at 2:43 pm

    I’m not sure if that’s what you’re asking, but the translations of th javascript messages are set in app/code/Core/Mage/Core/Helper/Js.php -> _getTranslateData() and is called in app/design/package/ theme/template/page/html/head.phtml <?php echo $this->helper('core/js')->getTranslatorScript() ?>

    I’ve just need that myself, let me refrase:

    1. in the phtml you add the strings you need to translate:

      <script type="text/javascript">
          //<![CDATA[
              Translator.add('String to translate', '<?php echo $this->__('String to translate'); ?>');
          //]]>
      </script>
      
    2. in your javascript file, use:

      Translator.translate('String to translate');
      
    3. now you can use your csv translations files

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

Sidebar

Related Questions

Can I use this approach efficiently? using(SqlCommand cmd = new SqlCommand(GetSomething, new SqlConnection(Config.ConnectionString)) {
You can use App.config; but it only supports key/value pairs. You can use .Net
How can I have a relative path in the web.config file. This value is
How can dynamic Key-value pairs of objects be stored in app.config in using the
How can one specify the connection string in a config file of a class
I want to know which *.config file the ConfigurationManager is using. How can I
Can anyone tell me where the config of cache folder is for phpbb3? I
How can I share/link App.config or Web.config between multiple projects in a visual studio
How can I change a key's value in web.config which is defined between appSettings
All the examples that I can search online use the App.Config mode of specifying

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.