Update: In a previous version, I wrote that the Messages.get() to retrieve an internationalized message required a fully-qualified path to the Messages class. There is an implicit object 'messages' which is less verbose and consistent with other template code.
In order to internationalize your application, store message resources -- labels, titles, etc. -- in a separate, language-specific file. Even if internationalization isn't a top priority, it's still beneficial to centralize the messages so they can be checked for consistency.
In the Play! Framework, the default layout will use the #{get} template tag to retrieve a page-specific title. From the generated layout page
<title>#{get 'title' /}</title>
An example page might define a title like this
<title>#{set 'title': 'My App' /}</title>
Alternatively, the title can be added to a message resources file like this
# screen messages
app.title=My App
Which can be applied to the #{set} tag as follows
<title>#{set 'title': messages.get("app.title") /}
</title>
The output for both #{set} examples is
Play! Title from Messages File |
No comments:
Post a Comment