Search code examples
variablesgettextpo

Can I have variables in .po files?


I'd like to use variables in some way in gettext .po files, for example:

msgid "ui_settings_connect_text"
msgstr "Connect to another running instance of " APP_NAME

Has anyone tried to do something like this before?


Solution

  • In your .po file:

    msgid "Connect to another running instance of %s"
    msgstr "Connect to another running instance of %s"
    

    In your app:

    printf(_("Connect to another running instance of %s"), app_name);