Skip to content

Commit 9f6e583

Browse files
authored
Merge pull request #850 from nextcloud-libraries/feat/detect-language
feat(gettext): Add `detectLanguage` method and deprecate `detectLocale`
2 parents 8e712a3 + becf57b commit 9f6e583

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66

77
All notable changes to this project will be documented in this file.
88

9+
## 3.2.0 - UNRELEASED
10+
### ℹ️ Notes
11+
The `GettextBuilder.detectLocale` method is deprecated and will be removed in the next major version.
12+
It is replaced with the `detectLanguage` method to make the method naming more consistent.
13+
14+
### Added
15+
- TBD
16+
### Fixed
17+
- TBD
18+
### Changed
19+
- TBD
20+
921
## 3.1.0 - 2024-05-07
1022

1123
### Added

lib/gettext.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,21 @@ class GettextBuilder {
3333
return this
3434
}
3535

36-
/** Try to detect locale from context with `en` as fallback value */
36+
/**
37+
* Try to detect locale from context with `en` as fallback value
38+
* This only works within a Nextcloud page context.
39+
*
40+
* @deprecated use `detectLanguage` instead.
41+
*/
3742
detectLocale(): GettextBuilder {
43+
return this.detectLanguage()
44+
}
45+
46+
/**
47+
* Try to detect locale from context with `en` as fallback value.
48+
* This only works within a Nextcloud page context.
49+
*/
50+
detectLanguage(): GettextBuilder {
3851
return this.setLanguage(getLanguage().replace('-', '_'))
3952
}
4053

0 commit comments

Comments
 (0)