2016-08-22 1 views
0
solutions de repli

J'ai un exemple ymls:Rails I18n pour hachage

en: 
    hello: 
    world: World 
    time: 
     am: "AM" 
     pm: "PM" 

ja: 
    hello: 
    world: 
    time: 
     am: "午前" 
     pm: "午後" 

travail bien quand je Fallback essaie d'appeler locale manquant:

I18n.locale = :ja 
I18n.t('hello.world') => 'World' 

Mais il retourne 'néant' sur certaines valeurs quand je vous appelle pour clé parent (hello):

I18n.locale = :ja 
I18n.t('hello') => { world: nil, time: { am: "午前", pm: "午後" } } 

Comment puis-je obtenir des traductions avec des solutions de repli: { world: 'World', time: { am: "午前", pm: "午後" } }

Merci!

Répondre

0

Avez-vous essayé d'appeler la méthode translate avec l'option :default => ''?

+0

comme ça? 'I18n.t ('bonjour', défaut:" ")' - le même résultat –

+0

Désolé, vous essayez d'obtenir le fallback de toute façon, pas une chaîne vide, mon mauvais. – JaschaL