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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:12:42+00:00 2026-05-14T00:12:42+00:00

I’m familiar with using NSLocalizedString() to localize strings, but the problem I have today

  • 0

I’m familiar with using NSLocalizedString() to localize strings, but the problem I have today requires a little more finesse. My situation is like this:

NSString *userName; //the users name, entered by the user.  Does not need localized
NSString *favoriteFood; //the users favorite food, also entered by user, and not needing localized

NSString *summary = [NSString stringWithFormat:@"%@'s favorite food is %@", userName, favoriteFood];

This works fine for english, but not every language uses the same word ordering as English, for example, a word-by-word translation of the same sentance from Japanese into English would read:

UserName’s favorite food pizza is

Not to mention that ‘s is doesn’t make a possessive in every language.

What techniques are available for localizing this type of concatenated sentence?

UPDATE FOR THE BENEFIT OF OTHERS:
@Jon Reed is right, positional specifiers are very important to localization. The document he linked only contains a reference to the fact that they can be used with NSString, NSLog, an others, the link doesn’t really tell HOW to use them.

I found this link, that explains it well. It also explains my question better than I did. From the link:

Format strings for printf and sprintf
(see Printf) present a special problem
for translation. Consider the
following:1

 printf(_"String `%s' has %d characters\n",
           string, length(string))) A possible German

translation for this might be:

 "%d Zeichen lang ist die Zeichenkette `%s'\n" The problem

should be obvious: the order of the
format specifications is different
from the original! Even though gettext
can return the translated string at
runtime, it cannot change the argument
order in the call to printf.

To solve this problem, printf format
specifiers may have an additional
optional element, which we call a
positional specifier. For example:

 "%2$d Zeichen lang ist die Zeichenkette `%1$s'\n" Here, the

positional specifier consists of an
integer count, which indicates which
argument to use, and a ‘$’. Counts are
one-based, and the format string
itself is not included. Thus, in the
following example, ‘string’ is the
first argument and ‘length(string)’ is
the second:

 $ gawk 'BEGIN {
 >     string = "Dont Panic"
 >     printf _"%2$d characters live in \"%1$s\"\n",
 >                         string, length(string)
 > }'
 -| 10 characters live in "Dont Panic"
  • 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-14T00:12:43+00:00Added an answer on May 14, 2026 at 12:12 am

    To specify order of substitution, use %1$@ and %2$@ as your format specifiers. The localized format string can use them in any order. For example, say your string key is “FavoriteFood”. Call

    NSString *summary =
                [NSString stringWithFormat:NSLocalizedString(@"FavoriteFood", nil), 
                                           userName, favoriteFood];
    

    The localization places the format specifiers wherever it makes sense for its locale. Example:

    "FavoriteFood" = "%2$@ is the favorite food of %1$@";
    

    See String Format Specifiers

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

Sidebar

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.