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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:59:24+00:00 2026-05-15T00:59:24+00:00

Ok, I’m using mathematical equations to output numbers, though, I need this to be

  • 0

Ok, I’m using mathematical equations to output numbers, though, I need this to be compatible for all languages. Currently, all language strings are within a php array called $txt, and each key of the array gets called for that language. I’m outputting the following: Column 1, Column 2, Column 3, and so on, as well as Row 1, Row 2, Row 3, and so on. The calculations are done via php and javascript, so I’m wondering on the best approach for how to support all languages for the numbers only.

I don’t do the translations, someone else does, but I need to be able to point it to, either the php variable $txt of where the language is defined, or, since the calculations are done via javascript also, I need to somehow store this in there. I’m thinking of storing something like this:

// This part goes in the php language file.
$txt['0'] = '0';
$txt['1'] = '1';
$txt['2'] = '2';
$txt['2'] = '3';
$txt['4'] = '4';
$txt['5'] = '5';
$txt['6'] = '6';
$txt['7'] = '7';
$txt['8'] = '8';
$txt['9'] = '9';

// This part goes in the php file that needs to call the numbers.
echo '<script>
    var numtxts = new Array();
    numtxts[0] = \'', $txt['0'], '\';
    numtxts[1] = \'', $txt['1'], '\';
    numtxts[2] = \'', $txt['2'], '\';
    numtxts[3] = \'', $txt['3'], '\';
    numtxts[4] = \'', $txt['4'], '\';
    numtxts[5] = \'', $txt['5'], '\';
    numtxts[6] = \'', $txt['6'], '\';
    numtxts[7] = \'', $txt['7'], '\';
    numtxts[8] = \'', $txt['8'], '\';
    numtxts[9] = \'', $txt['9'], '\';
</script>';

And than in the javascript function it could grab the correct string for each number like so:

// Example Number String below.
var numString = "10";
var transNum = "";

for(x=0;x<numString.length;x++)
{
    var numChar = numString.charAt(x);
    transNum += numtxts[parseInt(numChar)];
}

return transNum;

The problem with this bit of code is that it groups the numbers, not sure if all languages do that, like the english language does…?

Perhaps there’s a better approach for this? Can anyone help please?

Thanks 🙂

  • 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-15T00:59:24+00:00Added an answer on May 15, 2026 at 12:59 am

    To properly localize numbers, you’ll need much more complex logic. A quick example of roughly what you need to do:

    function localizeNumber($num, $lang) {
        switch ($lang) {
    
            case 'eng':
            case ...
                return number_format($num, 0);
    
            case 'deu':
            case ...
                return number_format($num, 0, ',', '.');
    
            case 'jpn':
                // TODO: learn about Kanji numerals and implement custom logic
                // Example: 3000 -> 三千, 30000 -> 三万, 321 -> 三百二十一
    
            ...
    
        }
    }
    

    There’s not much to do for most western cultures, just some have the thousand separator and the decimal point reversed. If you want to translate numbers into non-Arabic numerals, learn how the target numeric system works, then implement your own logic (or look around for existing libraries).

    Also note that although Japanese for example have “their own numerals” (borrowed from the Chinese), these days they usually prefer Arabic numbers. It depends on the context and what image you want to convey though, sometimes Chinese numerals are the better choice. This goes to say that there’s a whole lot of culture involved which you need to understand first.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.