-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from DFE-Digital/version-1.1.0
- Loading branch information
Showing
83 changed files
with
1,362 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
--- | ||
title: Localisation | ||
--- | ||
|
||
h1.govuk-heading-xl Localisation | ||
|
||
p.govuk-body | ||
| The simplest way of adding textual information like labels and hints to | ||
forms is to provide strings as arguments to the form helpers. | ||
|
||
.code-sample | ||
pre | ||
code.highlight.language-ruby | ||
| = f.govuk_text_field :name, label: { text: "Your full name" } | ||
|
||
p.govuk-body | ||
| On larger, more-complex projects, copy is spread throughout the application | ||
and often duplicated, making it difficult for content designers to make | ||
changes. | ||
|
||
p.govuk-body | ||
| Many teams approach this problem by making use of | ||
#{link_to("Rails' excellent localisation functionality", rails_localisation_link).html_safe}, | ||
allowing text to be stored in locale dictionaries. This allows editors to | ||
make changes without the risk of breaking templates and having to learn | ||
templating languages and hunt down content. | ||
|
||
section | ||
|
||
== render('/partials/example-fig.*', | ||
caption: "Populating label and hint text from the localisation data", | ||
localisation: favourite_kind_of_hat_locale, | ||
code: favourite_kind_of_hat) do | ||
|
||
p.govuk-body | ||
| Note that despite the <code>text</code> attribute being omitted from | ||
the label options hash, the other display and formatting parameters | ||
can be supplied and work in the normal manner. | ||
|
||
== render('/partials/example-fig.*', | ||
caption: "Customising locale structure", | ||
localisation: custom_locale, | ||
code: role_name, | ||
custom_config: custom_locale_config, | ||
raw_config: custom_locale_config_raw, | ||
hide_html_output: true) do | ||
|
||
p.govuk-body | ||
| There are many approaches to organising localisation data and while the default | ||
will work for most projects, sometimes a different approach can be beneficial. This | ||
is especially true when working with external localisation agencies or when dealing | ||
with large volumes of copy. | ||
|
||
p.govuk-body | ||
| To customise the location of our localisation strings, we can | ||
#{link_to('configure', '/introduction/configuration').html_safe} the schema as | ||
part of the application's initialisation process. | ||
|
||
h4.govuk-heading-s Contexts | ||
|
||
p.govuk-body | ||
| There are three contexts supported by the form builder: <em>label</em>, | ||
<em>legend</em> and <em>hint</em>. Custom locale schemas are | ||
configured using an array of symbols that match your locale structure. | ||
|
||
p.govuk-body | ||
| The special value <code>__context__</code> is used to represent the | ||
current translation context. It will automatically be replaced with | ||
either <em>label</em>, <em>legend</em> or <em>hint</em> when the | ||
translation key is generated. | ||
|
||
p.govuk-body | ||
| When retrieving a localised string the builder first checks whether | ||
a contextual schema has been set for the context. If there hasn't, | ||
the <code>localisation_schema_fallback</code> key will be used. <strong>It is | ||
the only one set by default</strong>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ $green: #00703c | |
$light-grey: #f3f2f1 | ||
$light-pink: lighten(#f499be, 20%) | ||
$red: #d4351c | ||
$dark-green: #365e07 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
title: Configuration | ||
--- | ||
|
||
h1.govuk-heading-xl Configuration | ||
|
||
p.govuk-body | ||
| The form builder's defaults follow the guidance specified in the | ||
GOV.UK Design System documentation, but every project is different | ||
and having to repeatedly override settings would soon become annoying. | ||
|
||
p.govuk-body | ||
| To configure the builder for your project, just create an initialiser | ||
in <code>config/initializers/govuk_design_system_formbuilder.rb</code>. | ||
|
||
.code-sample | ||
pre | ||
code.highlight.language-ruby | ||
| GOVUKDesignSystemFormBuilder.configure do |conf| | ||
conf.default_submit_button_text = 'Apply' # Continue | ||
conf.default_error_summary_title = 'Uh-oh, spaghettios' # There is a problem | ||
conf.default_legend_tag = 'h3' # h1 | ||
conf.default_legend_size = 'l' # m | ||
conf.default_radio_divider_text = 'how about' # or | ||
|
||
# localisation settings | ||
conf.localisation_schema_fallback = %i(myapp helpers __context__) | ||
conf.localisation_schema_label = nil | ||
conf.localisation_schema_hint = %i(myapp descriptions __context__) | ||
conf.localisation_schema_legend = %i(myapp descriptions __context__) | ||
end | ||
|
||
p.govuk-body | ||
| For a full list and description of configuration options | ||
#{link_to('check the documentation', config_documentation_link).html_safe} | ||
and for more information on setting up localisations for your application, there's | ||
a #{link_to('dedicated page in this guide', '/building-blocks/localisation').html_safe}. | ||
|
||
p.govuk-body | ||
| If there are any settings you'd like to be able to set defaults for but | ||
can't, #{link_to('raise an issue', project_new_issue_link).html_safe}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module Examples | ||
module Localisation | ||
def favourite_kind_of_hat_locale | ||
<<~LOCALE | ||
helpers: | ||
label: | ||
person: | ||
favourite_kind_of_hat: Which style of hat do you prefer? | ||
hint: | ||
person: | ||
favourite_kind_of_hat: |- | ||
Trilby, Stetson, Deerstalker, Fez, Top and Beret are | ||
the most-fashionable | ||
LOCALE | ||
end | ||
|
||
def favourite_kind_of_hat | ||
<<~SNIPPET | ||
= f.govuk_text_field :favourite_kind_of_hat, label: { size: 'm' } | ||
SNIPPET | ||
end | ||
|
||
def role_name | ||
<<~SNIPPET | ||
= f.govuk_text_field :role, label: { size: 'm' } | ||
SNIPPET | ||
end | ||
|
||
def custom_locale | ||
<<~LOCALE | ||
helpers: | ||
label: | ||
person: | ||
role: What role do you play? | ||
|
||
copy: | ||
descriptions: | ||
hint: | ||
subdivision: | ||
person: | ||
role: |- | ||
Roles may be achieved or ascribed or they can be accidental | ||
in different situations. An achieved role is a position | ||
that a person assumes voluntarily which reflects personal | ||
skills, abilities, and effort. | ||
LOCALE | ||
end | ||
|
||
def reset_config | ||
GOVUKDesignSystemFormBuilder.reset! | ||
end | ||
end | ||
end |
Oops, something went wrong.