chore: move i18n to shared package (#1066)

* chore: move i18n to shared package

* chore: move server translations to shared package and apply linter and prettier on entire shared package
This commit is contained in:
Julien G.
2026-05-26 20:27:29 +02:00
committed by GitHub
parent 324d930ca3
commit 126f2df21b
860 changed files with 56891 additions and 46377 deletions
+50 -10
View File
@@ -1,10 +1,11 @@
import { describe, it, expect } from 'vitest';
import {
weatherQuerySchema,
detailedWeatherQuerySchema,
weatherResultSchema,
} from './weather.schema';
import { describe, it, expect } from 'vitest';
describe('weatherQuerySchema', () => {
it('accepts lat/lng and defaults lang to "de"', () => {
const parsed = weatherQuerySchema.parse({ lat: '52.5', lng: '13.4' });
@@ -12,41 +13,80 @@ describe('weatherQuerySchema', () => {
});
it('keeps an explicit lang and optional date', () => {
const parsed = weatherQuerySchema.parse({ lat: '1', lng: '2', date: '2026-07-01', lang: 'en' });
const parsed = weatherQuerySchema.parse({
lat: '1',
lng: '2',
date: '2026-07-01',
lang: 'en',
});
expect(parsed.lang).toBe('en');
expect(parsed.date).toBe('2026-07-01');
});
it('rejects missing lat/lng', () => {
expect(weatherQuerySchema.safeParse({ lng: '13.4' }).success).toBe(false);
expect(weatherQuerySchema.safeParse({ lat: '', lng: '13.4' }).success).toBe(false);
expect(weatherQuerySchema.safeParse({ lat: '', lng: '13.4' }).success).toBe(
false,
);
});
});
describe('detailedWeatherQuerySchema', () => {
it('requires a date', () => {
expect(detailedWeatherQuerySchema.safeParse({ lat: '1', lng: '2' }).success).toBe(false);
expect(detailedWeatherQuerySchema.safeParse({ lat: '1', lng: '2', date: '2026-07-01' }).success).toBe(true);
expect(
detailedWeatherQuerySchema.safeParse({ lat: '1', lng: '2' }).success,
).toBe(false);
expect(
detailedWeatherQuerySchema.safeParse({
lat: '1',
lng: '2',
date: '2026-07-01',
}).success,
).toBe(true);
});
});
describe('weatherResultSchema', () => {
it('accepts a minimal current-weather result', () => {
const r = weatherResultSchema.parse({ temp: 21, main: 'Clear', description: 'Klar', type: 'current' });
const r = weatherResultSchema.parse({
temp: 21,
main: 'Clear',
description: 'Klar',
type: 'current',
});
expect(r.temp).toBe(21);
});
it('accepts a detailed result with hourly entries and a no_forecast error', () => {
expect(
weatherResultSchema.safeParse({
temp: 0, main: '', description: '', type: '', error: 'no_forecast',
temp: 0,
main: '',
description: '',
type: '',
error: 'no_forecast',
}).success,
).toBe(true);
expect(
weatherResultSchema.safeParse({
temp: 18, main: 'Rain', description: 'Regen', type: 'forecast',
sunrise: '05:30', sunset: '21:10', precipitation_sum: 2.4,
hourly: [{ hour: 9, temp: 17, precipitation: 0.1, precipitation_probability: 20, main: 'Clouds', wind: 12, humidity: 80 }],
temp: 18,
main: 'Rain',
description: 'Regen',
type: 'forecast',
sunrise: '05:30',
sunset: '21:10',
precipitation_sum: 2.4,
hourly: [
{
hour: 9,
temp: 17,
precipitation: 0.1,
precipitation_probability: 20,
main: 'Clouds',
wind: 12,
humidity: 80,
},
],
}).success,
).toBe(true);
});