Skip to content

Commit

Permalink
Language docs 4 0 (2600hz#3861)
Browse files Browse the repository at this point in the history
* get language with Default

* use account language/system language as default if config is missing

* add examples of setting up account prompts/language

* remove default language from schema

* fix xref issues

* one more time
  • Loading branch information
jamesaimonetti authored and k-anderson committed Jun 21, 2017
1 parent c904bcc commit 09b507d
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion applications/crossbar/doc/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Key | Description | Type | Default | Required
`do_not_disturb` | | `object` | | `false`
`do_not_disturb.enabled` | The default value for do-not-disturb | `boolean` | | `false`
`enabled` | Determines if the account is currently enabled | `boolean` | `true` | `false`
`language` | The language for this account | `string` | `en-us` | `false`
`language` | The language for this account | `string` | | `false`
`metaflows` | | `#/definitions/metaflows` | | `false`
`music_on_hold` | The default music on hold parameters | `object` | `{}` | `false`
`music_on_hold.media_id` | The ID of a media object that should be used as the default music on hold | `string(0..128)` | | `false`
Expand Down
2 changes: 1 addition & 1 deletion applications/crossbar/doc/ref/accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Key | Description | Type | Default | Required
`do_not_disturb` | | `object` | | `false`
`do_not_disturb.enabled` | The default value for do-not-disturb | `boolean` | | `false`
`enabled` | Determines if the account is currently enabled | `boolean` | `true` | `false`
`language` | The language for this account | `string` | `en-us` | `false`
`language` | The language for this account | `string` | | `false`
`metaflows` | | [#/definitions/metaflows](#metaflows) | | `false`
`music_on_hold` | The default music on hold parameters | `object` | `{}` | `false`
`music_on_hold.media_id` | The ID of a media object that should be used as the default music on hold | `string(0..128)` | | `false`
Expand Down
1 change: 0 additions & 1 deletion applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
"type": "boolean"
},
"language": {
"default": "en-us",
"description": "The language for this account",
"type": "string"
},
Expand Down
1 change: 0 additions & 1 deletion applications/crossbar/priv/couchdb/schemas/accounts.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"type": "boolean"
},
"language": {
"default": "en-us",
"description": "The language for this account",
"type": "string"
},
Expand Down
9 changes: 6 additions & 3 deletions core/kazoo_documents/src/kz_account.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

,name/1, name/2, set_name/2
,realm/1, realm/2, set_realm/2
,language/1, set_language/2
,language/1, language/2, set_language/2
,timezone/1, timezone/2, set_timezone/2
,parent_account_id/1
,tree/1, tree/2 ,set_tree/2
Expand Down Expand Up @@ -218,9 +218,12 @@ set_realm(JObj, Realm) ->
%% @doc
%% @end
%%--------------------------------------------------------------------
-spec language(doc()) -> api_binary().
-spec language(doc()) -> api_ne_binary().
-spec language(doc(), Default) -> ne_binary() | Default.
language(JObj) ->
kz_json:get_value(?LANGUAGE, JObj).
language(JObj, 'undefined').
language(JObj, Default) ->
kz_json:get_ne_binary_value(?LANGUAGE, JObj, Default).

%%--------------------------------------------------------------------
%% @public
Expand Down
10 changes: 8 additions & 2 deletions core/kazoo_media/src/kz_media_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,18 @@ prompt_language('undefined', Default) ->
default_prompt_language(Default);
prompt_language(<<_/binary>> = AccountId, 'undefined') ->
prompt_language(AccountId);
prompt_language(<<_/binary>> = AccountId, Default) ->
prompt_language(<<_/binary>> = AccountId, SystemDefault) ->
case ?USE_ACCOUNT_OVERRIDES of
'false' -> default_prompt_language();
'true' ->
{'ok', AccountJObj} = kz_account:fetch(AccountId),
Default = kz_account:language(AccountJObj, SystemDefault),
kz_util:to_lower_binary(
kapps_account_config:get(AccountId, ?CONFIG_CAT, ?PROMPT_LANGUAGE_KEY, kz_util:to_lower_binary(Default))
kapps_account_config:get(AccountId
,?CONFIG_CAT
,?PROMPT_LANGUAGE_KEY
,kz_util:to_lower_binary(Default)
)
)
end.

Expand Down
24 changes: 23 additions & 1 deletion doc/internationalization/prompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,34 @@ It is possible to create per-account prompts to be used in place of the system p

To do so, use the standard `PUT /media` but include `prompt_id` in the data payload with the name of the prompt.

curl -v -X PUT -H "X-Auth-Token: {AUTH_TOKEN}" http://server.com:8000/v2/accounts/{ACCOUNT_ID}/media -d '{"data":{"streamable":true,"name":"File","description":"Enter Pin prompt","prompt_id":"vm-enter_pin", "language":"x-pig-latin"}}'
```bash
curl -v -X PUT \
-H "X-Auth-Token: {AUTH_TOKEN}" \
http://server.com:8000/v2/accounts/{ACCOUNT_ID}/media \
-d '{"data":{"streamable":true,"name":"File","description":"Enter Pin prompt","prompt_id":"vm-enter_pin", "language":"x-pig-latin"}}'
```

##### Configure system to allow account overrides

Make sure the system is allowing accounts to override prompts

```bash
sup kapps_config set_default "media" "support_account_overrides" true
```

###### Set the account's language

Currently, a SUP command is required to set the account's language: `sup kapps_account_config set {ACCOUNT_ID} media default_language fr-ca`

You can also set it on the account doc with something like:

```bash
curl -X PATCH \
-H "X-Auth-Token: {AUTH_TOKEN}" \
-d '{"data":{"langauge":"es-es"}}' \
http://{SERVER}:8000/v2/accounts/{ACCOUNT_ID}
```

You can test what language will be selected for an account (barring a callflow language action changing it) thusly: `sup kz_media_util prompt_language {ACCOUNT_ID}`

##### System Prompts via Crossbar
Expand Down

0 comments on commit 09b507d

Please sign in to comment.