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.

Hello. Please, look at example code:

var locale = {
  en1:{
    msg1:"Test1",
    msg2:"Test2"
  },
  en2:{
    msg1:"Test1",
  }
}

Now, If I try to use $t(‘msg1’) when lang is set to “en2” I’ll see on screen “Test1”. But if I try to use $t(‘msg2’) I’ll see “msg2”. How can I set default lang, or what should I do, If I want to return default lang value, when the value is absent in current lang?

Issue Analytics

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

github_iconTop GitHub Comments

7reactions
mochettscommented, Aug 26, 2016

Hi @VegardSkui @guillaumevincent & @LuckyBlade.

I don’t know if you already solved this, but there’s a fallbackLang property as part of this package that can be set to the Vue.config object to fallback to a specific language.

So whenever bootstrapping your application besides setting the Vue.config.lang, also set Vue.config.fallbackLang.

e.g.: Vue.config.fallbackLang = 'en1'

That would solve your needs.

7reactions
guillaumevincentcommented, Dec 31, 2015

maybe the api could be more friendly like :

$t('msg2');
$t('msg2', 'default value');

it’s more declarative, can be extracted automatically, and always display a value, even if an error occurred.

Love the api in the v2 of Intl in FormatJS by yahoo

https://github.com/yahoo/react-intl/issues/162

Read more comments on GitHub >

github_iconTop Results From Across the Web

value expressions - produce the default value for any type
A default value expression produces the default value of a type. There are two kinds of default value expressions: the default operator call ......
Read more >
Documentation: 15: 5.2. Default Values - PostgreSQL
In a table definition, default values are listed after the column data type. For example: CREATE TABLE products ( product_no integer, name text,...
Read more >
SQL DEFAULT Constraint - W3Schools
The DEFAULT constraint is used to set a default value for a column. The default value will be added to all new records,...
Read more >
Specify default column values | BigQuery - Google Cloud
This page describes how to set a default value for a column in a BigQuery table. ... You can set the default value...
Read more >
Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
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