I18n: Add useT/useTranslate PR feedback that got missed (#102098)

I18n: Add PR feedback that got missed
This commit is contained in:
Josh Hunt
2025-03-13 12:49:49 +00:00
committed by GitHub
parent 2c1bc1bb7c
commit d6c97bd6c9
4 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -9,4 +9,4 @@
* and be subject to the standard policies
*/
export { useTranslate as useT, setUseTranslateHook } from './utils/i18n';
export { useTranslate, setUseTranslateHook } from './utils/i18n';
+3 -3
View File
@@ -5,7 +5,7 @@ type UseTranslateHook = () => (id: string, defaultMessage: string, values?: Reco
*/
export let useTranslate: UseTranslateHook = () => {
// Fallback implementation that should be overridden by setUseT
const errorMessage = 'useT is not set. useT must not be called before Grafana is initialized.';
const errorMessage = 'useTranslate is not set. useTranslate must not be called before Grafana is initialized.';
if (process.env.NODE_ENV === 'development') {
throw new Error(errorMessage);
}
@@ -16,6 +16,6 @@ export let useTranslate: UseTranslateHook = () => {
};
};
export function setUseTranslateHook(useTParam: UseTranslateHook) {
useTranslate = useTParam;
export function setUseTranslateHook(hook: UseTranslateHook) {
useTranslate = hook;
}
@@ -73,7 +73,7 @@ export const Trans = (props: TransProps): ReactElement => {
* Note: Don't use this in the top level module scope. This wrapper needs initialization, which is done during Grafana
* startup, and it will throw if used before.
*
* This will soon be deprecated in favor of useT()
* This will soon be deprecated in favor of useTranslate()
* @param id ID of the translation string
* @param defaultMessage Default message to use if the translation is missing
* @param values Values to be interpolated into the string
@@ -1,7 +1,7 @@
import { css } from '@emotion/css';
import { GrafanaTheme2, NavModelItem } from '@grafana/data';
import { useT } from '@grafana/runtime/src/unstable';
import { useTranslate } from '@grafana/runtime/src/unstable';
import { EmptyState, useStyles2 } from '@grafana/ui';
import { usePinnedItems } from 'app/core/components/AppChrome/MegaMenu/hooks';
import { findByUrl } from 'app/core/components/AppChrome/MegaMenu/utils';
@@ -11,7 +11,7 @@ import { Trans } from 'app/core/internationalization';
import { useSelector } from 'app/types';
export function BookmarksPage() {
const t = useT();
const t = useTranslate();
const styles = useStyles2(getStyles);
const pinnedItems = usePinnedItems();
const navTree = useSelector((state) => state.navBarTree);