You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature related to a specific framework or general for this extension
Probably this request relates to other frameworks as well, but we use React-Native.
Is your feature request related to a problem? Please describe.
No, not a problem, but an enhancement
Describe the solution you'd like
We are using a custom hook that takes care of the capitalization of the translated string. Depending on the used hook-function it will capitalize the string accordingly. See the added code of the hook so you will understand the purpose and working.
It would be great if i18n-ally supports the use of a custom hook like this, or maybe even better, that this hook/functionality is embeded in i18n-ally itself as a new feature.
Additional context
This is the code of the hook:
import { useTranslation } from "react-i18next";
/**
* Returns an object with translation functions for use in React components.
*
* @return {Object} An object containing four translation functions:
* - `t`: The original translation function from `useTranslation`.
* - `T`: Capitalizes the first letter of the translated string.
* - `TT`: Capitalizes the first letter of each word in the translated string.
* - `TTT`: Converts the translated string to uppercase.
*/
function useTranslate() {
const { t } = useTranslation();
const T = (key: string, params: object = {}) => {
const translation = t(key, params);
const result = translation.charAt(0).toUpperCase() + translation.slice(1);
return result;
};
const TT = (key: string, params: object = {}) => {
const translation = t(key, params);
const result = translation
.split(" ")
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ");
return result;
};
const TTT = (key: string, params: object = {}) => {
const translation = t(key, params);
const result = translation.toUpperCase();
return result;
};
return { t, T, TT, TTT };
}
export default useTranslate;
The text was updated successfully, but these errors were encountered:
Is your feature related to a specific framework or general for this extension
Probably this request relates to other frameworks as well, but we use React-Native.
Is your feature request related to a problem? Please describe.
No, not a problem, but an enhancement
Describe the solution you'd like
We are using a custom hook that takes care of the capitalization of the translated string. Depending on the used hook-function it will capitalize the string accordingly. See the added code of the hook so you will understand the purpose and working.
It would be great if i18n-ally supports the use of a custom hook like this, or maybe even better, that this hook/functionality is embeded in i18n-ally itself as a new feature.
Additional context
This is the code of the hook:
The text was updated successfully, but these errors were encountered: