Skip to content

Commit

Permalink
(feat) Add options parameter to translateFrom (#329)
Browse files Browse the repository at this point in the history
* (feat) Add options parameter to translateFrom

* Fixup
  • Loading branch information
brandones authored Feb 17, 2022
1 parent cc32c3f commit 3faa18d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/framework/esm-framework/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -3977,7 +3977,7 @@ ___

### translateFrom

**translateFrom**(`moduleName`, `key`, `fallback?`): `string`
**translateFrom**(`moduleName`, `key`, `fallback?`, `options?`): `string`

#### Parameters

Expand All @@ -3986,6 +3986,7 @@ ___
| `moduleName` | `string` |
| `key` | `string` |
| `fallback?` | `string` |
| `options?` | `object` |

#### Returns

Expand Down Expand Up @@ -4551,7 +4552,7 @@ a route listener is set up to update the patient whenever the route changes.

#### Defined in

[packages/framework/esm-react-utils/src/usePatient.ts:86](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-react-utils/src/usePatient.ts#L86)
[packages/framework/esm-react-utils/src/usePatient.ts:91](https://github.com/openmrs/openmrs-esm-core/blob/master/packages/framework/esm-react-utils/src/usePatient.ts#L91)

___

Expand Down
4 changes: 3 additions & 1 deletion packages/framework/esm-utils/src/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import _i18n from "i18next";
export function translateFrom(
moduleName: string,
key: string,
fallback?: string
fallback?: string,
options?: object
) {
const i18n: typeof _i18n = (_i18n as any).default || _i18n;
return i18n.t(key, {
ns: moduleName,
defaultValue: fallback,
...options,
});
}

0 comments on commit 3faa18d

Please sign in to comment.