ar-design 0.1.45 → 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { useContext, useEffect, useRef, useState } from "react";
|
|
2
3
|
import { ConfigContext } from "../contexts/Config";
|
|
3
4
|
import { NotificationContext } from "../contexts/Notification";
|
|
@@ -85,11 +86,14 @@ export const useValidation = function (data, params) {
|
|
|
85
86
|
errors,
|
|
86
87
|
};
|
|
87
88
|
};
|
|
88
|
-
// Custom hook for easier usage of context
|
|
89
89
|
export const useTranslation = function (translations) {
|
|
90
90
|
const t = (key, ...args) => {
|
|
91
91
|
if (typeof window !== "undefined") {
|
|
92
|
-
|
|
92
|
+
const getLanguage = localStorage.getItem("ar-language-value");
|
|
93
|
+
if (getLanguage)
|
|
94
|
+
return Utils.StringFormat(translations[getLanguage][key], args);
|
|
95
|
+
else
|
|
96
|
+
localStorage.setItem("ar-language-value", "tr");
|
|
93
97
|
}
|
|
94
98
|
return "";
|
|
95
99
|
};
|
|
@@ -99,5 +103,6 @@ export const useTranslation = function (translations) {
|
|
|
99
103
|
window.location.reload();
|
|
100
104
|
}
|
|
101
105
|
};
|
|
102
|
-
|
|
106
|
+
const currentLanguage = typeof window !== "undefined" ? localStorage.getItem("ar-language-value") : null;
|
|
107
|
+
return { t, changeLanguage, currentLanguage };
|
|
103
108
|
};
|