@sankhyalabs/core-docs 6.1.0-ms.2 → 6.1.0-ms.3
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.
- package/classes/LangUtils.md +195 -0
- package/globals.md +1 -0
- package/package.json +1 -1
@@ -0,0 +1,195 @@
|
|
1
|
+
[**@sankhyalabs/core**](../README.md) • **Docs**
|
2
|
+
|
3
|
+
***
|
4
|
+
|
5
|
+
[@sankhyalabs/core](../globals.md) / LangUtils
|
6
|
+
|
7
|
+
# Class: LangUtils
|
8
|
+
|
9
|
+
A classe `LangUtils` fornece métodos utilitários para gerenciar configurações de
|
10
|
+
idioma, incluindo recuperar, definir e aplicar preferências de idioma.
|
11
|
+
|
12
|
+
## Constructors
|
13
|
+
|
14
|
+
### new LangUtils()
|
15
|
+
|
16
|
+
> **new LangUtils**(): [`LangUtils`](LangUtils.md)
|
17
|
+
|
18
|
+
#### Returns
|
19
|
+
|
20
|
+
[`LangUtils`](LangUtils.md)
|
21
|
+
|
22
|
+
## Properties
|
23
|
+
|
24
|
+
### ELanguages
|
25
|
+
|
26
|
+
> `static` **ELanguages**: *typeof* `__class`
|
27
|
+
|
28
|
+
Classe estática contendo os códigos de idioma predefinidos.
|
29
|
+
|
30
|
+
#### Source
|
31
|
+
|
32
|
+
src/utils/LangUtils.ts:14
|
33
|
+
|
34
|
+
## Methods
|
35
|
+
|
36
|
+
### applyLanguageFromCookie()
|
37
|
+
|
38
|
+
> `static` **applyLanguageFromCookie**(): `void`
|
39
|
+
|
40
|
+
Define o atributo `lang` no elemento `<html>` com base no cookie de idioma, se existir.
|
41
|
+
|
42
|
+
#### Returns
|
43
|
+
|
44
|
+
`void`
|
45
|
+
|
46
|
+
#### Example
|
47
|
+
|
48
|
+
```ts
|
49
|
+
LangUtils.applyLanguageFromCookie(); // Aplica o idioma do cookie ao elemento `<html>`
|
50
|
+
```
|
51
|
+
|
52
|
+
#### Source
|
53
|
+
|
54
|
+
src/utils/LangUtils.ts:123
|
55
|
+
|
56
|
+
***
|
57
|
+
|
58
|
+
### convertLanguage()
|
59
|
+
|
60
|
+
> `static` `private` **convertLanguage**(`lang`): `string`
|
61
|
+
|
62
|
+
Converte o idioma fornecido para um dos códigos predefinidos.
|
63
|
+
|
64
|
+
#### Parameters
|
65
|
+
|
66
|
+
• **lang**: `string`
|
67
|
+
|
68
|
+
O idioma a ser convertido (ex.: "en", "es", "pt-BR").
|
69
|
+
|
70
|
+
#### Returns
|
71
|
+
|
72
|
+
`string`
|
73
|
+
|
74
|
+
O código de idioma correspondente (ex.: "en_US", "es_ES").
|
75
|
+
|
76
|
+
#### Example
|
77
|
+
|
78
|
+
```ts
|
79
|
+
LangUtils.convertLanguage("en"); // Retorna "en_US"
|
80
|
+
LangUtils.convertLanguage("es-es"); // Retorna "es_ES"
|
81
|
+
```
|
82
|
+
|
83
|
+
#### Source
|
84
|
+
|
85
|
+
src/utils/LangUtils.ts:30
|
86
|
+
|
87
|
+
***
|
88
|
+
|
89
|
+
### getHtmlLanguage()
|
90
|
+
|
91
|
+
> `static` **getHtmlLanguage**(): `string`
|
92
|
+
|
93
|
+
Recupera o valor do atributo `lang` do elemento `<html>`. Se o ambiente
|
94
|
+
estiver em modo de desenvolvimento, o idioma padrão será `"pt_BR"`. Caso
|
95
|
+
contrário, utiliza o idioma do navegador ou `"pt-BR"` como padrão.
|
96
|
+
|
97
|
+
#### Returns
|
98
|
+
|
99
|
+
`string`
|
100
|
+
|
101
|
+
O idioma definido no elemento `<html>` ou o padrão.
|
102
|
+
|
103
|
+
#### Example
|
104
|
+
|
105
|
+
```ts
|
106
|
+
LangUtils.getHtmlLanguage(); // Retorna "pt_BR" no modo desenvolvimento
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Source
|
110
|
+
|
111
|
+
src/utils/LangUtils.ts:77
|
112
|
+
|
113
|
+
***
|
114
|
+
|
115
|
+
### getLanguage()
|
116
|
+
|
117
|
+
> `static` **getLanguage**(): `string`
|
118
|
+
|
119
|
+
Captura o idioma atualmente definido. Primeiro verifica se há um idioma
|
120
|
+
armazenado nos cookies. Caso contrário, utiliza o idioma definido no elemento
|
121
|
+
`<html>`. Se nenhum valor for encontrado nos cookies ou no elemento `<html>`,
|
122
|
+
é utilizada a configuração do navegador. Caso o navegador também não forneça
|
123
|
+
um idioma, o padrão será `"pt_BR"`.
|
124
|
+
|
125
|
+
#### Returns
|
126
|
+
|
127
|
+
`string`
|
128
|
+
|
129
|
+
O idioma definido (ex.: "pt_BR", "en_US").
|
130
|
+
|
131
|
+
#### Example
|
132
|
+
|
133
|
+
```ts
|
134
|
+
LangUtils.getLanguage(); // Retorna o idioma atual
|
135
|
+
```
|
136
|
+
|
137
|
+
#### Source
|
138
|
+
|
139
|
+
src/utils/LangUtils.ts:57
|
140
|
+
|
141
|
+
***
|
142
|
+
|
143
|
+
### getLanguageFromCookie()
|
144
|
+
|
145
|
+
> `static` **getLanguageFromCookie**(): `null` \| `string`
|
146
|
+
|
147
|
+
Recupera o valor do cookie de idioma.
|
148
|
+
|
149
|
+
#### Returns
|
150
|
+
|
151
|
+
`null` \| `string`
|
152
|
+
|
153
|
+
O valor do cookie de idioma ou `null` se não existir.
|
154
|
+
|
155
|
+
#### Example
|
156
|
+
|
157
|
+
```ts
|
158
|
+
LangUtils.getLanguageFromCookie(); // Retorna "pt_BR" se o cookie existir
|
159
|
+
```
|
160
|
+
|
161
|
+
#### Source
|
162
|
+
|
163
|
+
src/utils/LangUtils.ts:112
|
164
|
+
|
165
|
+
***
|
166
|
+
|
167
|
+
### setHtmlLanguage()
|
168
|
+
|
169
|
+
> `static` **setHtmlLanguage**(`language`): `void`
|
170
|
+
|
171
|
+
Define o atributo `lang` no elemento `<html>` e atualiza o cookie de idioma.
|
172
|
+
|
173
|
+
#### Parameters
|
174
|
+
|
175
|
+
• **language**: `string`
|
176
|
+
|
177
|
+
O idioma a ser definido (ex.: "pt_BR", "en_US").
|
178
|
+
|
179
|
+
> **Nota:** Definir o idioma no elemento `<html>` é essencial para garantir que o conteúdo
|
180
|
+
da página seja interpretado corretamente por navegadores, leitores de tela e mecanismos de
|
181
|
+
busca, melhorando a acessibilidade e a indexação.
|
182
|
+
|
183
|
+
#### Returns
|
184
|
+
|
185
|
+
`void`
|
186
|
+
|
187
|
+
#### Example
|
188
|
+
|
189
|
+
```ts
|
190
|
+
LangUtils.setHtmlLanguage("en_US"); // Define o idioma como "en_US"
|
191
|
+
```
|
192
|
+
|
193
|
+
#### Source
|
194
|
+
|
195
|
+
src/utils/LangUtils.ts:99
|
package/globals.md
CHANGED
@@ -46,6 +46,7 @@
|
|
46
46
|
- [IDBRepository](classes/IDBRepository.md)
|
47
47
|
- [JSUtils](classes/JSUtils.md)
|
48
48
|
- [KeyboardManager](classes/KeyboardManager.md)
|
49
|
+
- [LangUtils](classes/LangUtils.md)
|
49
50
|
- [LockManager](classes/LockManager.md)
|
50
51
|
- [MaskFormatter](classes/MaskFormatter.md)
|
51
52
|
- [NumberUtils](classes/NumberUtils.md)
|