Skip to content

Commit

Permalink
Merge branch 'develop' into feat/profiles
Browse files Browse the repository at this point in the history
  • Loading branch information
naumovski-filip authored Aug 3, 2023
2 parents 08ef531 + 6216bd2 commit 78c114c
Show file tree
Hide file tree
Showing 31 changed files with 342 additions and 114 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ firebase-debug.log

# Exclude ini files because they have customer specific data
ini/*.ini

# Ignore working area for i18n checks
.temp-translations
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# [4.25.0](https://github.com/jwplayer/ott-web-app/compare/v4.23.2...v4.25.0) (2023-08-01)


### Bug Fixes

* add missing Spanish translations ([2270049](https://github.com/jwplayer/ott-web-app/commit/22700493c6e3bb9a247684aa353002d68cbde509))
* add per-provider flag for subscription change tests ([19cd475](https://github.com/jwplayer/ott-web-app/commit/19cd4752177a0c816e257a1192337b41664af37b))
* choose offer modal without pricing options ([bc8389e](https://github.com/jwplayer/ott-web-app/commit/bc8389e3ab9f0c343e25d3dcf60f139b56204f34))
* disable change subscription button when subscription is cancelled and can't renew ([be09ba2](https://github.com/jwplayer/ott-web-app/commit/be09ba2b3cb8ae6688e7673f8216e31b02e38bf0))
* hide cancel button for inplayer configs ([8f71448](https://github.com/jwplayer/ott-web-app/commit/8f714488fc5d21725f9a8d1286326f38c7b9608c))
* move additional logic to container ([7a350fa](https://github.com/jwplayer/ott-web-app/commit/7a350fab301e841d9a7c126033e6045247fbec52))
* move logic from user and payment to paymentcontainer ([6b7a72a](https://github.com/jwplayer/ott-web-app/commit/6b7a72ab5126431f8a19dae18cd992d1f59cffd6))
* move useoffers call to payments ([1cfcf45](https://github.com/jwplayer/ott-web-app/commit/1cfcf454231d101d9975c50958fb07d32dfff9dd))
* offerswitch props ([d79f779](https://github.com/jwplayer/ott-web-app/commit/d79f779c7ac9a7ff5a46ce4702df68f8145fa572))
* pr comments ([c9d5bbb](https://github.com/jwplayer/ott-web-app/commit/c9d5bbba4f1c29adf733d678a981a6cfd968574f))
* remove unnecessary redirect ([4a8a5ff](https://github.com/jwplayer/ott-web-app/commit/4a8a5ff75759ba76fd07361cc2f7670f70a9ade7))
* **seo:** fix seo score ([2274c9b](https://github.com/jwplayer/ott-web-app/commit/2274c9b5999507a96f781ee5d5ba1501b00036e5))
* tests ([0654af6](https://github.com/jwplayer/ott-web-app/commit/0654af6665bc1b542ea1148fb64cc00806b8446b))
* **watchhistory:** improve watch history storage calls and fix bugs ([9fd1774](https://github.com/jwplayer/ott-web-app/commit/9fd17746d27490d43fe6f595252bba29c9e20d02))


### Features

* initial inplayer subscription change implementation ([b335b69](https://github.com/jwplayer/ott-web-app/commit/b335b69f6429bb73a72cd8a442f5e52fdf77084b))
* **project:** add new `cardImageAspectRatio` custom param for playlists ([65264eb](https://github.com/jwplayer/ott-web-app/commit/65264eb5ae99fcbfb9348de01e9ed6a8f64c9cf0))
* **project:** fix lhci workflow ([466e8e3](https://github.com/jwplayer/ott-web-app/commit/466e8e3650d769bdcf324539d7c27e1fb6d8df11))
* **project:** lighthouse actions triggering ([0d004eb](https://github.com/jwplayer/ott-web-app/commit/0d004eb216c4dec331be93e0c35d3e369861b11a))
* **project:** lighthouse check ([3ba3617](https://github.com/jwplayer/ott-web-app/commit/3ba36174b114a46905942ed3ede1f085654c9729))
* **project:** remove ImageData type ([6f993c6](https://github.com/jwplayer/ott-web-app/commit/6f993c608a98fa4c6269a0ccf69058f434054f81))
* **project:** use a native fallback for image service ([0fc9bd6](https://github.com/jwplayer/ott-web-app/commit/0fc9bd6fcf71d43e336d1759410a2a5a5c40352b))
* **series:** add native support for next episodes ([1f11d6a](https://github.com/jwplayer/ott-web-app/commit/1f11d6a445813957277abcaedf3975ec6fb05bc1))
* **series:** use named params ([ba6560e](https://github.com/jwplayer/ott-web-app/commit/ba6560e53ac291e671b53c9206eeaf197c135253))
* temporary FE handling for downgrade subscription ([53ee10d](https://github.com/jwplayer/ott-web-app/commit/53ee10d7e26c9a9dea5454c00ae869b115169a7d))



## [4.23.2](https://github.com/jwplayer/ott-web-app/compare/v4.23.1...v4.23.2) (2023-07-06)


Expand Down
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jw-ott-webapp",
"version": "4.23.2",
"version": "4.25.0",
"main": "index.js",
"repository": "https://github.com/jwplayer/ott-web-app.git",
"author": "JW Player",
Expand All @@ -19,6 +19,8 @@
"test-commit": "TZ=UTC LC_ALL=en_US.UTF-8 vitest run --changed HEAD~1 --coverage",
"test-update": "TZ=UTC LC_ALL=en_US.UTF-8 vitest run --update",
"i18next": "i18next src/{components,containers,pages,services,stores}/**/{**/,/}*.{ts,tsx} && node ./scripts/i18next/generate.js",
"i18next-diff": "yarn i18next && npx ts-node ./scripts/i18next/diff-translations",
"i18next-update": "npx ts-node ./scripts/i18next/update-translations && yarn i18next",
"format": "run-s -c format:*",
"format:eslint": "eslint \"{**/*,*}.{js,ts,jsx,tsx}\" --fix",
"format:prettier": "prettier --write \"{**/*,*}.{js,ts,jsx,tsx}\"",
Expand Down Expand Up @@ -54,12 +56,12 @@
"marked": "^4.1.1",
"payment": "^2.4.6",
"planby": "^0.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"react-i18next": "^12.2.2",
"react-infinite-scroller": "^1.2.6",
"react-query": "^3.13.10",
"react-query": "^3.39.0",
"react-router-dom": "^6.4.0",
"wicg-inert": "^3.1.1",
"yup": "^0.32.9",
Expand All @@ -80,8 +82,8 @@
"@types/marked": "^4.0.7",
"@types/node": "^17.0.23",
"@types/payment": "^2.1.4",
"@types/react": "^17.0.14",
"@types/react-dom": "^17.0.9",
"@types/react": "^18.2.15",
"@types/react-dom": "18.2.7",
"@types/react-helmet": "^6.1.2",
"@types/react-infinite-scroller": "^1.2.3",
"@typescript-eslint/eslint-plugin": "^5.17.0",
Expand All @@ -91,6 +93,7 @@
"allure-commandline": "^2.17.2",
"codeceptjs": "3.4.1",
"confusing-browser-globals": "^1.0.10",
"csv-parse": "^5.4.0",
"depcheck": "^1.4.3",
"eslint": "^7.31.0",
"eslint-plugin-codeceptjs": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"close": "Cancel",
"confirm": "Yes"
},
"default_site_name": "My OTT Application",
"default_description": "JW OTT Webapp is an open-source, dynamically generated video website.",
"default_site_name": "My OTT Application",
"filter_videos_by": "Filter videos by {{name}}",
"filter_videos_by_genre": "Filter videos by genre",
"home": "Home",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/en/demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"app_config_not_found": "Invalid or Missing App Config",
"app_config_learn_more": "Learn more about App Configs",
"app_config_not_found": "Invalid or Missing App Config",
"cancel_config_id": "Cancel",
"click_to_unselect_config": "(click here to unselect this config)",
"currently_previewing_config": "You are currently previewing config: '{{configSource}}'",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"close": "Cancelar",
"confirm": ""
},
"default_site_name": "Mi aplicación OTT",
"default_description": "La OTT WebApp de JW es un sitio web de videos de código abierto generado dinamicamente.",
"default_site_name": "Mi aplicación OTT",
"filter_videos_by": "Filtrar videos por {{name}}",
"filter_videos_by_genre": "Filtrar videos por género",
"home": "Inicio",
Expand Down
2 changes: 1 addition & 1 deletion public/locales/es/demo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"app_config_not_found": "Configuración de aplicación inválida o no encontrada",
"app_config_learn_more": "Más información sobre App Configs",
"app_config_not_found": "Configuración de aplicación inválida o no encontrada",
"cancel_config_id": "Cancelar",
"click_to_unselect_config": "(haz clic aquí para deseleccionar esta configuración)",
"currently_previewing_config": "Actualmente estás previsualizando la configuración: '{{configSource}}'",
Expand Down
14 changes: 7 additions & 7 deletions public/locales/es/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@
"billing_history": "Historial de facturación",
"cancel_subscription": "Cancelar suscripción",
"card_number": "Número de tarjeta",
"change_plan": "",
"change_plan_error": "",
"change_plan": "Cambiar De Plan",
"change_plan_error": "Hubo un problema al guardar los cambios en el plan de tu suscripción.",
"change_subscription": "Cambiar suscripción",
"complete_subscription": "Completar suscripción",
"current_plan": "",
"current_plan": "PLAN ACTUAL",
"daily_subscription": "Suscripción diaria",
"downgrade_on": "",
"downgrade_plan_success": "",
"downgrade_on": "Degradaciónde plan pendiente para el {{date}}",
"downgrade_plan_success": "Haz cambiado exitosamente el plan de tu suscripción. Tu nuevo plan comenzará después de que finalice el periodo actual el {{date}}.",
"expiry_date": "Fecha de vencimiento",
"granted_subscription": "Suscripción otorgada",
"hidden_transactions_one": "Una transacción más",
Expand All @@ -98,7 +98,7 @@
"no_transactions": "No hay transacciones",
"other": "otro",
"payment_method": "Método de pago",
"pending_downgrade": "",
"pending_downgrade": "Degradación de plan pendiente",
"pending_offer_switch": "Se actualizará a \"{{title}}\" después de la próxima fecha de facturación",
"price_paid_with": "{{price}} pagado con {{method}}",
"price_paid_with_card": "Precio pagado con tarjeta",
Expand All @@ -109,7 +109,7 @@
"subscription_details": "Detalles de la suscripción",
"subscription_expires_on": "Este plan expirará el {{date}}",
"update_payment_details": "Actualizar detalles de pago",
"upgrade_plan_success": "",
"upgrade_plan_success": "Haz cambiado exitosamente el plan de tu suscripción. Puedes comenzar a disfrutar de los beneficios adicionales de inmediato.",
"weekly_subscription": "Suscripción semanal"
},
"profile": {
Expand Down
112 changes: 112 additions & 0 deletions scripts/i18next/diff-translations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { execSync } from 'child_process';
import * as fs from 'fs';

const changes: {
[file: string]: {
[key: string]: {
[language: string]: {
oldValue?: string;
newValue?: string;
};
};
};
} = {};

function run() {
const fileChanges = execSync('git diff -U200000 --no-prefix release..release-candidate public/locales')
.toString()
.split('\n')
.filter((s) => !!s)
.map((s) => s.trim());

let filename = '';
let language = '';
let path: string[] = [];

for (const line of fileChanges) {
if (line.startsWith('diff --git')) {
[filename, language] = line.split('\n')[0].split('/').reverse() || [];
path = [];
} else if (line.startsWith('"') && line.endsWith('{')) {
// This is the start of a new subgroup, parse the name and add it to the path
path.push(line.split(':')[0].replace(/"/g, ''));
} else if (line.startsWith('}')) {
// This is the end of a subgroup, so take last path segment away
path.pop();
} else if (line.startsWith('---') || line.startsWith('+++')) {
// Skip these lines
} else if (line.startsWith('+') || line.startsWith('-')) {
// This is a changed line, first parse the value
// using regex to strip the leading +/-, whitespace, and quotes OR trailing quote and comma
// Then split on the colon and middle quotes
const [name, value] = line.replace(/(^[+-]\s*")|(",$)/g, '').split('": "');

// Reconstruct the full path from any parent paths
const key = [...path, name].join('.');

// Make sure that the nested items have values
changes[filename] ||= {};
changes[filename][key] ||= {};
changes[filename][key][language] ||= {};

// Set the old or new value props based on the git symbol
if (line.startsWith('+')) {
changes[filename][key][language].newValue = value;
} else {
changes[filename][key][language].oldValue = value;
}
}
}

const languageGroups: {
[language: string]: string[];
} = {};

Object.entries(changes).forEach(([filename, fileChanges]) => {
Object.entries(fileChanges).forEach(([key, languages]) => {
Object.entries(languages).forEach(([language, props]) => {
// Only include keys with updated new values or where the English has updated new values
if (languages['en'].newValue !== undefined || props.newValue !== undefined) {
// Add the headers
languageGroups[language] ||= [
[
'File',
'Translation Key',
// Show Old/New English fields for other languages to help translators
...(language === 'en' ? [] : ['Original Value (en)', 'New Value (en)']),
`Original Value (${language})`,
`Updated Value (${language})`,
].join(','),
];

languageGroups[language].push(
[
filename,
key,
// Show Old/New English values for other languages to help translators
...(language === 'en' ? [] : [languages['en']?.oldValue || '', languages['en']?.newValue || '']),
props.oldValue || '',
props.newValue || '',
]
// Wrap with quotes to escape any internal commas
.map((v) => `"${v}"`)
.join(','),
);
}
});
});
});

if (!fs.existsSync('.temp-translations')) {
fs.mkdirSync('.temp-translations');
}

Object.entries(languageGroups).forEach(([language, values]) => {
const file = `.temp-translations/translations.${language}.csv`;

fs.writeFileSync(file, values.join('\n'), 'utf8');
console.info(`Wrote ${values.length - 1} keys to ${file}`);
});
}

run();
9 changes: 9 additions & 0 deletions scripts/i18next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"include": ["./**/*"],
"compilerOptions": {
"module": "NodeNext",
"types": [
"node"
]
},
}
60 changes: 60 additions & 0 deletions scripts/i18next/update-translations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import * as fs from 'fs';

// @ts-ignore
import { ColumnOption, parse } from 'csv-parse/sync';

interface Line {
filename: string;
key: string;
value: string;
}

interface JsonObject {
[key: string]: string | JsonObject;
}

function updateObject(obj: JsonObject, paths: string[], newValue: string) {
const key = paths.shift() || '';

if (paths.length <= 0) {
obj[key] = newValue;
} else {
obj[key] = updateObject(obj[key] as JsonObject, paths, newValue);
}

return obj;
}

function run() {
const allFiles = fs.readdirSync('.temp-translations');

for (const file of allFiles) {
const language = file.split('.')[1];

const lines = parse(fs.readFileSync(`.temp-translations/${file}`), {
fromLine: 2,
columns: ['filename', 'key', ...(language === 'en' ? [] : [false as ColumnOption, false as ColumnOption]), false, 'value'],
relax_column_count: true,
}) as Line[];
const groups = lines.reduce((allGroups, line) => {
allGroups[line.filename] ||= [];
allGroups[line.filename].push(line);

return allGroups;
}, {} as { [filename: string]: Line[] });

Object.entries(groups).forEach(([jsonFile, lines]) => {
const filename = `public/locales/${language}/${jsonFile}`;

const json = JSON.parse(fs.readFileSync(filename).toString());

for (const line of lines) {
updateObject(json, line.key.split('.'), line.value);
}

fs.writeFileSync(filename, JSON.stringify(json));
});
}
}

run();
1 change: 0 additions & 1 deletion src/components/Account/__snapshots__/Account.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ exports[`<Account> > renders and matches snapshot 1`] = `
<label
for="check-box_1235_consents.marketing"
>
Receive Marketing Emails
</label>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/Animation/Animation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type Props = {
open?: boolean;
duration?: number;
delay?: number;
children?: React.ReactNode;
keepMounted?: boolean;
onOpenAnimationEnd?: () => void;
onCloseAnimationEnd?: () => void;
Expand Down
3 changes: 2 additions & 1 deletion src/components/Animation/Fade/Fade.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { CSSProperties } from 'react';
import React, { CSSProperties, ReactNode } from 'react';

import Animation, { Status } from '#components/Animation/Animation';

Expand All @@ -7,6 +7,7 @@ type Props = {
open?: boolean;
duration?: number;
delay?: number;
children?: ReactNode;
keepMounted?: boolean;
onOpenAnimationEnd?: () => void;
onCloseAnimationEnd?: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ exports[`<Checkbox> > renders and matches snapshot 1`] = `
<label
for="check-box_1235_name"
>
label
</label>
</div>
Expand Down
Loading

0 comments on commit 78c114c

Please sign in to comment.