Yaml (yml) file gotchas – trying to set default culture to “no”

The yaml file parser will attempt to parse all the values, rather than taking them as they are – which in most cases is a good thing, however you must remember to use quotes when the intended output is a string, and the parser may interpret the value otherwise:

default_culture:   en
// No problem, en is treated as a string 
// and /en/ is automatically added to links
default_culture: no
// Oops, no is translated by Symfony 
// the same way as false, 0 or off, giving it a boolean value!
default_culture: 'no'
// That's better, now you will have the intended results.

The same applies to any yml files that you may have “keywords” in, so try to always use quotes round everything that is not boolean, integer, etc.

I18n is for life (actions), not just for Christmas (templates)

Well, the point is make sure you Internationalise everything, not just the text you have in the templates.

For example, when using ajax calls you may be rendering text directly from actions, or you may be throwing exceptions which have meaningful error messages which are displayed by the template. You need to remember to “i18nalise” this text too…

From an action, you can access the i18n function via the context singleton, as documented by the Symfony docs (http://www.symfony-project.org/book/1_0/13-I18n-and-L10n)


Remember to do it now, and you won’t kick yourself later!