@@ -4,12 +4,13 @@ import { Dropdown, DropdownItem } from "flowbite-react";
44import { MdSpeed } from 'react-icons/md' ;
55import { FaBatteryHalf , FaBolt , FaCog , FaEye , FaGlobe , FaPlus } from 'react-icons/fa' ;
66import { BsRulers } from 'react-icons/bs' ;
7- import i18n from "@/utils/i18n" ;
87import { FlowBiteConstants } from "@/utils/constants" ;
8+ import { useTranslation } from "react-i18next" ;
99
1010type ActionType = 'accelerometer' | 'current' | 'encoder' | 'gyroscope' | 'rangefinder' | 'reflectance' | 'voltage' ;
1111
1212const AddWidgets : React . FC = ( ) => {
13+ const { t } = useTranslation ( ) ;
1314 const { addWidget } = useGridStackContext ( ) ;
1415
1516 const handleAction = ( action : ActionType ) => {
@@ -24,7 +25,7 @@ const AddWidgets: React.FC = () => {
2425 minW : 2 ,
2526 minH : 5 ,
2627 content : JSON . stringify ( {
27- name : i18n . t ( 'accelerometer' ) ,
28+ name : 'Accelerometer' ,
2829 props : {
2930 isActive : true
3031 // Remove widgetId - we'll get it from GridStack
@@ -44,7 +45,7 @@ const AddWidgets: React.FC = () => {
4445 minW : 1 ,
4546 minH : 5 ,
4647 content : JSON . stringify ( {
47- name : i18n . t ( 'current' ) ,
48+ name : 'Current' ,
4849 props : {
4950 isActive : true
5051 } ,
@@ -63,7 +64,7 @@ const AddWidgets: React.FC = () => {
6364 minW : 2 ,
6465 minH : 5 ,
6566 content : JSON . stringify ( {
66- name : i18n . t ( 'gyroscope' ) ,
67+ name : 'Gyroscope' ,
6768 props : {
6869 isActive : true
6970 } ,
@@ -82,7 +83,7 @@ const AddWidgets: React.FC = () => {
8283 minW : 1 ,
8384 minH : 4 ,
8485 content : JSON . stringify ( {
85- name : i18n . t ( 'encoder' ) ,
86+ name : 'Encoder' ,
8687 props : {
8788 isActive : true
8889 } ,
@@ -101,7 +102,7 @@ const AddWidgets: React.FC = () => {
101102 minW : 2 ,
102103 minH : 5 ,
103104 content : JSON . stringify ( {
104- name : i18n . t ( 'reflectance' ) ,
105+ name : 'Reflectance' ,
105106 props : {
106107 isActive : true
107108 } ,
@@ -120,7 +121,7 @@ const AddWidgets: React.FC = () => {
120121 minW : 2 ,
121122 minH : 6 ,
122123 content : JSON . stringify ( {
123- name : i18n . t ( 'voltage' ) ,
124+ name : 'Voltage' ,
124125 props : {
125126 isActive : true
126127 } ,
@@ -139,7 +140,7 @@ const AddWidgets: React.FC = () => {
139140 minW : 2 ,
140141 minH : 8 ,
141142 content : JSON . stringify ( {
142- name : i18n . t ( 'rangefinder' ) ,
143+ name : 'Rangefinder' ,
143144 props : {
144145 isActive : true
145146 } ,
@@ -155,13 +156,13 @@ const AddWidgets: React.FC = () => {
155156 return (
156157 < div className = "flex items-center mt-4 sm:mt-0" >
157158 < Dropdown label = { < FaPlus size = { 20 } /> } inline = { true } theme = { FlowBiteConstants . DropdownTheme } className = "flex items-center mt-4 sm:mt-0 " >
158- < DropdownItem icon = { MdSpeed } onClick = { ( ) => handleAction ( 'accelerometer' ) } > Accelerometer </ DropdownItem >
159- < DropdownItem icon = { FaBolt } onClick = { ( ) => handleAction ( 'current' ) } > Current </ DropdownItem >
160- < DropdownItem icon = { FaGlobe } onClick = { ( ) => handleAction ( 'gyroscope' ) } > Gyroscope </ DropdownItem >
161- < DropdownItem icon = { FaCog } onClick = { ( ) => handleAction ( 'encoder' ) } > Encoder </ DropdownItem >
162- < DropdownItem icon = { FaEye } onClick = { ( ) => handleAction ( 'reflectance' ) } > Reflectance </ DropdownItem >
163- < DropdownItem icon = { BsRulers } onClick = { ( ) => handleAction ( 'rangefinder' ) } > Rangefinder </ DropdownItem >
164- < DropdownItem icon = { FaBatteryHalf } onClick = { ( ) => handleAction ( 'voltage' ) } > Voltage </ DropdownItem >
159+ < DropdownItem icon = { MdSpeed } onClick = { ( ) => handleAction ( 'accelerometer' ) } > { t ( 'accelerometer' ) } </ DropdownItem >
160+ < DropdownItem icon = { FaBolt } onClick = { ( ) => handleAction ( 'current' ) } > { t ( 'current' ) } </ DropdownItem >
161+ < DropdownItem icon = { FaGlobe } onClick = { ( ) => handleAction ( 'gyroscope' ) } > { t ( 'gyroscope' ) } </ DropdownItem >
162+ < DropdownItem icon = { FaCog } onClick = { ( ) => handleAction ( 'encoder' ) } > { t ( 'encoders' ) } </ DropdownItem >
163+ < DropdownItem icon = { FaEye } onClick = { ( ) => handleAction ( 'reflectance' ) } > { t ( 'reflectance' ) } </ DropdownItem >
164+ < DropdownItem icon = { BsRulers } onClick = { ( ) => handleAction ( 'rangefinder' ) } > { t ( 'rangefinder' ) } </ DropdownItem >
165+ < DropdownItem icon = { FaBatteryHalf } onClick = { ( ) => handleAction ( 'voltage' ) } > { t ( 'voltage' ) } </ DropdownItem >
165166 </ Dropdown >
166167 </ div >
167168 ) ;
0 commit comments