Merge branch 'hungs-feedback' into 'master'
fix: Read live view signing salt from env See merge request mythic-insight/legendary!56
This commit is contained in:
commit
3c0b9b22fe
5 changed files with 26 additions and 5 deletions
|
@ -8,7 +8,7 @@ allows non-developers on a team to make copy changes.
|
||||||
2. When your application supports multiple languages, it is easy for translators
|
2. When your application supports multiple languages, it is easy for translators
|
||||||
to provide translations for all of your copy at once.
|
to provide translations for all of your copy at once.
|
||||||
|
|
||||||
In Legendary, we provide a set of tools for doing this.
|
In Legendary, we provide a set of tools for doing this via [linguist](https://github.com/change/linguist).
|
||||||
|
|
||||||
- (English) strings are stored in config/i18n/en.yml.
|
- (English) strings are stored in config/i18n/en.yml.
|
||||||
- You can call `Legendary.I18n.t!/2` to get a string by its key. For example: `Legendary.I18n.t! "en", "site.title"` retrieves the english version of the
|
- You can call `Legendary.I18n.t!/2` to get a string by its key. For example: `Legendary.I18n.t! "en", "site.title"` retrieves the english version of the
|
||||||
|
@ -20,5 +20,20 @@ string labeled "title" under the section "site" on en.yml.
|
||||||
Note that the first argument is a two-letter language code. In order to support
|
Note that the first argument is a two-letter language code. In order to support
|
||||||
other languages, you can provide more yml files in config/i18n (example, config/i18n/fr.yml for French) and call t!/2 with that language code instead.
|
other languages, you can provide more yml files in config/i18n (example, config/i18n/fr.yml for French) and call t!/2 with that language code instead.
|
||||||
|
|
||||||
|
Linguist also supports templated translations. If you have a section in en.yml like this:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
app:
|
||||||
|
hello_message: Hello, %{name}!
|
||||||
|
```
|
||||||
|
|
||||||
|
then you could call `t!` substitutions like this:
|
||||||
|
|
||||||
|
```elixir
|
||||||
|
t! "en", "app.hello_message", name: "Legend"
|
||||||
|
```
|
||||||
|
|
||||||
|
to get the string "Hello, legend!"
|
||||||
|
|
||||||
**On the roadmap:** in the future, we intend to provide a mechanism for detecting
|
**On the roadmap:** in the future, we intend to provide a mechanism for detecting
|
||||||
and managing each visitor's language and providing those strings if available.
|
and managing each visitor's language and providing those strings if available.
|
||||||
|
|
|
@ -27,7 +27,7 @@ Since Legendary is both a template and a framework, you can simply clone the rep
|
||||||
to start using it. It's a fully functional Phoenix app as-is. To start a new project:
|
to start using it. It's a fully functional Phoenix app as-is. To start a new project:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git clone git@gitlab.com:mythic-insight/legendary.git <project_name>
|
git clone https://gitlab.com/mythic-insight/legendary.git <project_name>
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to start the server, run `script/server`. Any dependencies required
|
In order to start the server, run `script/server`. Any dependencies required
|
||||||
|
|
|
@ -11,6 +11,7 @@ use Mix.Config
|
||||||
# before starting your production server.
|
# before starting your production server.
|
||||||
|
|
||||||
secret_key_base = System.get_env("SECRET_KEY_BASE")
|
secret_key_base = System.get_env("SECRET_KEY_BASE")
|
||||||
|
signing_salt = System.get_env("LIVE_VIEW_SIGNING_SALT")
|
||||||
|
|
||||||
[
|
[
|
||||||
{:admin, Legendary.Admin, false},
|
{:admin, Legendary.Admin, false},
|
||||||
|
@ -35,7 +36,7 @@ secret_key_base = System.get_env("SECRET_KEY_BASE")
|
||||||
],
|
],
|
||||||
secret_key_base: secret_key_base,
|
secret_key_base: secret_key_base,
|
||||||
pubsub_server: App.PubSub,
|
pubsub_server: App.PubSub,
|
||||||
live_view: [signing_salt: "g5ltUbnQ"],
|
live_view: [signing_salt: signing_salt],
|
||||||
server: start_server
|
server: start_server
|
||||||
] ++ extra_opts
|
] ++ extra_opts
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -34,6 +34,11 @@ spec:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: legendary
|
name: legendary
|
||||||
key: secret-key-base
|
key: secret-key-base
|
||||||
|
- name: LIVE_VIEW_SIGNING_SALT
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: legendary
|
||||||
|
key: live-view-signing-salt
|
||||||
---
|
---
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Service
|
kind: Service
|
||||||
|
|
|
@ -12,7 +12,7 @@ else
|
||||||
export KERL_CONFIGURE_OPTIONS="--disable-hipe --with-ssl=$(brew --prefix openssl)"
|
export KERL_CONFIGURE_OPTIONS="--disable-hipe --with-ssl=$(brew --prefix openssl)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! asdf -v &> /dev/null
|
if ! which asdf &> /dev/null
|
||||||
then
|
then
|
||||||
echo "WARNING: No asdf. Skipping erlang, elixir, node installation."
|
echo "WARNING: No asdf. Skipping erlang, elixir, node installation."
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue