fusionjs / fusion-cli

Migrated to https://github.com/fusionjs/fusionjs
MIT License
140 stars 37 forks source link

Improved Translation API via Hooks #645

Open ganemone opened 5 years ago

ganemone commented 5 years ago

We should investigate if we can improve our translations API using hooks.

Type of issue

Feature Request

Description

The current API for working with raw translated strings is a bit cumbersome, as it requires duplicating the translation keys, once in the withTranslations call, and once in the translate call. This is further described here: https://github.com/fusionjs/fusion-cli/pull/643

We should investigate various options of improving this API, potentially taking advantage of hooks.

ganemone commented 5 years ago

A potential hook API could look something like this:

import {useTranslate} from 'fusion-plugin-i18n-react';

function Component() {
  const translate = useTranslate();
  const value = translate('some.key');
}