What are the types of formatting?
Assesses fundamental understanding of Vue.js conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
Basically there are 4 types of formatting available in i18n plugin,
- Named formatting: First You need to define the message keys in curly braces({})
const messages = {
en: {
message: {
greeting: '{msg} Morning'
}
}
}
After that pass argument value along with key in the template
<p>{{ $t('message.greeting', { msg: 'Good' }) }}</p>
It outputs the result as below,
<p>Good Morning</p>
- List formatting: First you need to define zero index based keys in the messages,
const messages = {
en: {
message: {
greeting: '{0} Morning'
}
}
}
After that pass argument value with in an array
<p>{{ $t('message.greeting', ['Good']) }}</p>
Finally it outputs the result as below,
<p>Good morning</p>
Note: It also accepts array-like object
<p>{{ $t('message.greeting', {'0': 'Good'}) }}</p>
- HTML formatting: This formatting is required when want to render your translation as an HTML message and not
a static string.
const messages = {
en: {
message: {
greeting: 'Good <br> Morning'
}
}
}
After that use it in the html directive template as below
<p v-html="$t('message.greeting')"></p>
Finally it outputs the result as below
<p>Good
<!--<br> exists but is rendered as html and not a string-->
Morning</p>
- Ruby on rails format: First you need to define with percentile and curly braces as below,
const messages = {
en: {
message: {
greeting: '%{msg} Morning'
}
}
}
After that pass argument with key similar to named formatting
<p>{{ $t('message.greeting', { msg: 'Good' }) }}</p>
Finally it renders the output as below,
<p>Good Morning</p>
****
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.