summaryrefslogtreecommitdiffstats
path: root/web_src/js/utils.test.js
diff options
context:
space:
mode:
authorYarden Shoham <hrsi88@gmail.com>2022-10-28 16:48:24 +0300
committerGitHub <noreply@github.com>2022-10-28 09:48:24 -0400
commit125e3e3d66d117d23e387c083d22a8d90820bb52 (patch)
treef70c2bd88cf339970f96d193bc0908a35a22be11 /web_src/js/utils.test.js
parent76e9a4f701880d798d90a3e069e571052e342da8 (diff)
downloadgitea-125e3e3d66d117d23e387c083d22a8d90820bb52.tar.gz
gitea-125e3e3d66d117d23e387c083d22a8d90820bb52.zip
Localize time units on activity heatmap (#21570)
Previously, the months and days were hardcoded into English * Closes #15541 ## Screenshots ### English ![image](https://user-images.githubusercontent.com/20454870/197410352-1b28a637-ce19-41ae-b4e5-27955555b082.png) ### German ![image](https://user-images.githubusercontent.com/20454870/197410455-f243ca84-807f-476e-b8ed-c24e827bfc2d.png) ### Spanish ![image](https://user-images.githubusercontent.com/20454870/197410366-55202ca5-08f9-4152-8f9d-d5eeebd532ef.png) ### Italian ![image](https://user-images.githubusercontent.com/20454870/197410385-75f754dd-e845-4444-8a04-472a8f45b617.png) ### Portuguese This one has a bit of overflow ![image](https://user-images.githubusercontent.com/20454870/197410414-b91f962e-77e9-4cc7-990b-01c0fc0cbd0b.png) Signed-off-by: Yarden Shoham <hrsi88@gmail.com> Co-authored-by: Gusted <williamzijl7@hotmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src/js/utils.test.js')
-rw-r--r--web_src/js/utils.test.js24
1 files changed, 23 insertions, 1 deletions
diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js
index 7bf5bb7eb6..0567a5c64a 100644
--- a/web_src/js/utils.test.js
+++ b/web_src/js/utils.test.js
@@ -1,7 +1,7 @@
import {expect, test} from 'vitest';
import {
basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref,
- prettyNumber, parseUrl,
+ prettyNumber, parseUrl, translateMonth, translateDay
} from './utils.js';
test('basename', () => {
@@ -109,3 +109,25 @@ test('parseUrl', () => {
expect(parseUrl('https://localhost/path?search').search).toEqual('?search');
expect(parseUrl('https://localhost/path?search#hash').hash).toEqual('#hash');
});
+
+test('translateMonth', () => {
+ const originalLang = document.documentElement.lang;
+ document.documentElement.lang = 'en-US';
+ expect(translateMonth(0)).toEqual('Jan');
+ expect(translateMonth(4)).toEqual('May');
+ document.documentElement.lang = 'es-ES';
+ expect(translateMonth(5)).toEqual('jun');
+ expect(translateMonth(6)).toEqual('jul');
+ document.documentElement.lang = originalLang;
+});
+
+test('translateDay', () => {
+ const originalLang = document.documentElement.lang;
+ document.documentElement.lang = 'fr-FR';
+ expect(translateDay(1)).toEqual('lun.');
+ expect(translateDay(5)).toEqual('ven.');
+ document.documentElement.lang = 'pl-PL';
+ expect(translateDay(1)).toEqual('pon.');
+ expect(translateDay(5)).toEqual('pt.');
+ document.documentElement.lang = originalLang;
+});