Vue.js Medium technical 0 views 2 min read

What are the types of formatting?

Peer-reviewed by HireXTech Technical Panel Updated for 2025/2026 hiring Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of Vue.js conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

Basically there are 4 types of formatting available in i18n plugin,

  1. 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>
   
  1. 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>
   
  1. 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>
   
  1. 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

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?