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.
@@ -49,4 +49,5 @@ export declare const useTranslation: <TBaseLocale>(translations: {
49
49
  }) => {
50
50
  t: (key: keyof TBaseLocale, ...args: any[]) => string;
51
51
  changeLanguage: (language: string) => void;
52
+ currentLanguage: string | null;
52
53
  };
@@ -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
- return Utils.StringFormat(translations[localStorage.getItem("ar-language-value")][key], args);
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
- return { t, changeLanguage };
106
+ const currentLanguage = typeof window !== "undefined" ? localStorage.getItem("ar-language-value") : null;
107
+ return { t, changeLanguage, currentLanguage };
103
108
  };
@@ -2,7 +2,7 @@ class Api {
2
2
  _host;
3
3
  _core;
4
4
  constructor(values) {
5
- this._host = values.host || window.location.origin;
5
+ this._host = values.host || typeof window !== "undefined" ? window.location.origin : "";
6
6
  this._core = values.core || "";
7
7
  }
8
8
  async Get(values) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ar-design",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",