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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:58:50+00:00 2026-05-15T11:58:50+00:00

what should be the best approach to make strings for different languages? I have

  • 0

what should be the best approach to make strings for different languages? I have this problem, I am trying to display strings such as ‘month’, ‘months’, ‘year’, ‘years’. Currently I am working on 3 languages I know: spanish, english and polish. For english and spanish this is straight forward. But for instance, in polish ‘years’ can become ‘lata’ (after numbers 2 – 4) or ‘lat’ (after numbers from 5). I was thinking on adding an extra string for this, and making it empty in the other languages. However this made me think about the other languages I don’t know, which might have even more differences. Which should be the best approach in this case, if I am considering adding more languages in the future?

  • 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-15T11:58:51+00:00Added an answer on May 15, 2026 at 11:58 am

    Sounds like you want a ChoiceFormat, or at least using one through a MessageFormat:

    public static void main(String... args) {
        String[] formats = { 
            // NOTE - In a real app, you'd fetch the format strings from a language,
            // file, not hard-code them in your program. Obviously.
            "{0,number} {0,choice,0#years|1#year|1<years}", // english
            "{0,number} {0,choice,0#años|1#año|1<años}", // spanish
            "{0,number} {0,choice,1#[fewer than 2]|2#lata|4<lat}", // polish
            "{0,number} år", // swedish - singular and plural forms look the same!
        };
        int[] years = {0, 1, 2, 3, 4, 5, 6};
        for (int year : years) {
            for (String format : formats) {
                System.out.println(MessageFormat.format(format, year));
            }
            System.out.println();
        }
    }
    

    In your program, you would of course get the format string from your string file.

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

Sidebar

Related Questions

I'm trying to figure the best approach to solve this problem. -- I have
Trying to figure out the best way to do this: Should I do something
I'm trying to make an App-wide media-upload which should have the possibility of being
How should I best approach drawing a scatter plot diagram in Cocoa?
I have a console application that should do best effort logging to a database
This is a security best practice and I'm wondering if I should even be
Greetings, I'm confused as to the best approach to make when consuming REST based
I'm a Mongo newbie, and trying to make this schema work. Its intended for
I'm trying to figure out the best approach for a c++ program: I need
About best practices on designing stored procedures, should a stored procedure updating a record

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.