question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

interpolate variables into translation strings

See original GitHub issue

Translation strings must not be concatenated with variables - the variables need to be interpolated using ICU message syntax

example 1:

      deleteConfirmation: 'Are you sure you want to remove ',
      from: ' from ',
      still: 'You can still access this account from ',

example 2:

      deleteConfirmation: 'Are you sure you want to delete ',

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rtibblescommented, Apr 25, 2017

Good to avoid it if possible, definitely,at least until we can come up with some better sanitisation on string import.

1reaction
indirectlylitcommented, Apr 24, 2017

nope, but searching vue files for these two regexes find some strings with leading and trailing space:

  • : ' .+',
  • : '.+ ',

results:

Searching 126 files for ": ' .+'," (regex)

/Users/d/Projects/learning_equality/repos/kolibri/kolibri/plugins/coach/assets/src/views/attempt-log-list/index.vue:
   50        today: 'Today',
   51        yesterday: 'Yesterday',
   52:       daysAgo: ' { daysElapsed } days ago',
   53        question: 'Question { questionNumber, number }',
   54      },

/Users/d/Projects/learning_equality/repos/kolibri/kolibri/plugins/management/assets/src/views/class-edit-page/user-remove-modal.vue:
   47        // confirmation messages
   48        deleteConfirmation: 'Are you sure you want to remove ',
   49:       from: ' from ',
   50        still: 'You can still access this account from ',
   51        users: 'Users',

2 matches across 2 files


Searching 126 files for ": '.+ '," (regex)

/Users/d/Projects/learning_equality/repos/kolibri/kolibri/plugins/management/assets/src/views/class-edit-page/user-remove-modal.vue:
   46        cancel: 'Cancel',
   47        // confirmation messages
   48:       deleteConfirmation: 'Are you sure you want to remove ',
   49:       from: ' from ',
   50:       still: 'You can still access this account from ',
   51        users: 'Users',
   52      },

/Users/d/Projects/learning_equality/repos/kolibri/kolibri/plugins/management/assets/src/views/manage-class-page/class-delete-modal.vue:
   47        description: 'Users will only be removed from the class and are still accessible from the "Users" tab.',
   48        // confirmation messages
   49:       deleteConfirmation: 'Are you sure you want to delete ',
   50      },
   51      components: {

4 matches across 2 files

I’d say fixing those is good enough for this task. We could potentially do a deeper audit of all translated strings but I think that’d be overkill at the moment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interpolation - i18next documentation
Interpolation is one of the most used functionalities in I18N. It allows integrating dynamic values into your translations.
Read more >
How To Pass a Variable to Your Translation String With i18next
Let's learn how i18next interpolation works and how you can use this feature to pass one or more dynamic values to your translation...
Read more >
How to use i18n string interpolation - zargony.com
Here, the translation uses string interpolation to put variable values into a meaningful sentence. The translation string itself is a ...
Read more >
i18n Attaching variable to translation string - Stack Overflow
I am currently using i18n to translate strings and I'm looking for a way to attach a variable onto the path. This variable...
Read more >
Interpolation I (GNU gettext utilities)
Perl is capable of interpolating variables into strings. This offers some nice features in localized programs but can also lead to problems.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found