Skip to content

Commit 1da0a1d

Browse files
Merge branch 'develop' into user-leaveorg
2 parents 69d0c2c + 959399d commit 1da0a1d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+16510
-27130
lines changed

.github/workflows/compare_translations.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,31 @@ def compare_translations(default_translation,
8888
errors.append(error_msg)
8989
return errors
9090

91+
def flatten_json(nested_json, parent_key=""):
92+
"""
93+
Flattens a nested JSON, concatenating keys to represent the hierarchy.
94+
95+
Args:
96+
nested_json (dict): The JSON object to flatten.
97+
parent_key (str): The base key for recursion (used to track key hierarchy).
98+
99+
Returns:
100+
dict: A flattened dictionary with concatenated keys.
101+
"""
102+
flat_dict = {}
103+
104+
for key, value in nested_json.items():
105+
# Create the new key by concatenating parent and current key
106+
new_key = f"{parent_key}.{key}" if parent_key else key
107+
108+
if isinstance(value, dict):
109+
# Recursively flatten the nested dictionary
110+
flat_dict.update(flatten_json(value, new_key))
111+
else:
112+
# Assign the value to the flattened key
113+
flat_dict[new_key] = value
114+
115+
return flat_dict
91116

92117
def load_translation(filepath):
93118
"""Load translation from a file.
@@ -104,7 +129,8 @@ def load_translation(filepath):
104129
if not content.strip():
105130
raise ValueError(f"File {filepath} is empty.")
106131
translation = json.loads(content)
107-
return translation
132+
flattened_translation = flatten_json(translation)
133+
return flattened_translation
108134
except json.JSONDecodeError as e:
109135
raise ValueError(f"Error decoding JSON from file {filepath}: {e}")
110136

@@ -170,7 +196,7 @@ def main():
170196
"--directory",
171197
type=str,
172198
nargs="?",
173-
default=os.path.join(os.getcwd(), "locales"),
199+
default=os.path.join(os.getcwd(), "public/locales"),
174200
help="Directory containing translation files(relative to the root directory).",
175201
)
176202
args = parser.parse_args()

config/babel.config.cjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
presets: [
3+
'@babel/preset-env', // Transforms modern JavaScript
4+
'@babel/preset-typescript', // Transforms TypeScript
5+
'@babel/preset-react', // Transforms JSX
6+
],
7+
plugins: ['babel-plugin-transform-import-meta'],
8+
};

config/vite.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { defineConfig } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
import viteTsconfigPaths from 'vite-tsconfig-paths';
4+
import svgrPlugin from 'vite-plugin-svgr';
5+
import EnvironmentPlugin from 'vite-plugin-environment';
6+
7+
export default defineConfig({
8+
// depending on your application, base can also be "/"
9+
build: {
10+
outDir: 'build',
11+
},
12+
base: '',
13+
plugins: [
14+
react(),
15+
viteTsconfigPaths(),
16+
EnvironmentPlugin('all'),
17+
svgrPlugin({
18+
svgrOptions: {
19+
icon: true,
20+
// ...svgr options (https://react-svgr.com/docs/options/)
21+
},
22+
}),
23+
],
24+
server: {
25+
// this ensures that the browser opens upon server start
26+
open: true,
27+
// this sets a default port to 3000
28+
port: 4321,
29+
},
30+
});
Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="icon" href="%PUBLIC_URL%/favicon_palisadoes.ico" />
5+
<link rel="icon" href="/favicon_palisadoes.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#000000" />
8-
<link rel="apple-touch-icon" href="%PUBLIC_URL%/favicon.ico" />
9-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
8+
<link rel="apple-touch-icon" href="/favicon.ico" />
9+
<link rel="manifest" href="/manifest.json" />
1010
<link rel="preconnect" href="https://fonts.googleapis.com" />
1111
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1212
<link
@@ -18,10 +18,15 @@
1818
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
1919
referrerpolicy="no-referrer"
2020
/>
21-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" referrerpolicy="no-referrer" />
21+
<link
22+
rel="stylesheet"
23+
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
24+
referrerpolicy="no-referrer"
25+
/>
2226
<title>Talawa Admin</title>
2327
</head>
2428
<body>
2529
<div id="root"></div>
30+
<script type="module" src="/src/index.tsx"></script>
2631
</body>
2732
</html>

jest.config.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
export default {
22
roots: ['<rootDir>/src'],
33
collectCoverageFrom: ['src/**/*.{ts,tsx}', '!src/index.tsx'],
4-
setupFiles: ['react-app-polyfill/jsdom'],
4+
// setupFiles: ['react-app-polyfill/jsdom'],
5+
setupFiles: ['whatwg-fetch'],
56
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
67
testMatch: [
78
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
89
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
910
],
1011
testEnvironment: 'jsdom',
1112
transform: {
12-
'^.+\\.(js|jsx|mjs|cjs|ts|tsx)$':
13-
'react-scripts/config/jest/babelTransform.js',
14-
'^.+\\.(css|scss|sass|less)$': 'jest-preview/transforms/css',
15-
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)':
16-
'jest-preview/transforms/file',
13+
'^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { configFile: "./config/babel.config.cjs" }], // Use babel-jest for JavaScript and TypeScript files
14+
'^.+\\.(css|scss|sass|less)$': 'jest-preview/transforms/css', // CSS transformations
15+
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': 'jest-preview/transforms/file', // File transformations
1716
},
1817
transformIgnorePatterns: [
1918
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$',
@@ -28,6 +27,8 @@ export default {
2827
'^@dicebear/core$': '<rootDir>/scripts/__mocks__/@dicebear/core.ts',
2928
'^@dicebear/collection$':
3029
'<rootDir>/scripts/__mocks__/@dicebear/collection.ts',
30+
'\\.svg\\?react$': '<rootDir>/scripts/__mocks__/fileMock.js',
31+
'\\.svg$': '<rootDir>/scripts/__mocks__/fileMock.js',
3132
},
3233
moduleFileExtensions: [
3334
'web.js',
@@ -41,10 +42,10 @@ export default {
4142
'jsx',
4243
'node',
4344
],
44-
watchPlugins: [
45-
'jest-watch-typeahead/filename',
46-
'jest-watch-typeahead/testname',
47-
],
45+
// watchPlugins: [
46+
// 'jest-watch-typeahead/filename',
47+
// 'jest-watch-typeahead/testname',
48+
// ],
4849
resetMocks: false,
4950
coveragePathIgnorePatterns: [
5051
'src/state/index.ts',

0 commit comments

Comments
 (0)