Skip to content

Commit aaf3150

Browse files
author
Guillermo Machado
committed
chore: remove arabic translation
1 parent 4db48ae commit aaf3150

File tree

8 files changed

+172
-104
lines changed

8 files changed

+172
-104
lines changed

scripts/sonarqube.sh

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Configuration
2+
SONAR_HOST_URL="https://sonarqube-developers.rootstrap.net"
3+
SONAR_API_TOKEN="squ_21cf7e64993c3df2b83511539c16429a28ec1d17"
4+
#!/bin/bash
5+
6+
#!/bin/bash
7+
8+
# Check if fzf is installed, and install it if it's missing
9+
if ! command -v fzf &>/dev/null; then
10+
echo "fzf is not installed. Installing fzf via Homebrew..."
11+
12+
# Check if Homebrew is installed
13+
if command -v brew &>/dev/null; then
14+
brew install fzf
15+
else
16+
echo "Homebrew is not installed. Please install Homebrew f irst: https://brew.sh/"
17+
exit 1
18+
fi
19+
fi
20+
21+
### Step 1: Retrieve the project name ###
22+
echo ""
23+
read -p "Please enter the project name: " project_name
24+
25+
# Confirm the entered project name
26+
if [[ -z "$project_name" ]]; then
27+
echo "No project name provided. Exiting."
28+
exit 1
29+
fi
30+
31+
echo "You have entered project name: $project_name"
32+
33+
### Step 2: Retrieve and select Quality Profile ###
34+
# Fetch the list of quality profiles
35+
quality_profiles_response=$(curl -s -X GET "$SONAR_HOST_URL/api/qualityprofiles/search" \
36+
-H "Authorization: Bearer $SONAR_API_TOKEN")
37+
38+
# Check if the response contains any profiles
39+
if ! echo "$quality_profiles_response" | grep -q '"profiles"'; then
40+
echo "Failed to retrieve quality profiles. Response:"
41+
echo "$quality_profiles_response"
42+
exit 1
43+
fi
44+
45+
# Extract and display the names of the quality profiles using jq and fzf for selection
46+
selected_quality_profile=$(echo "$quality_profiles_response" | jq -r '.profiles[] | "\(.languageName) (\(.name))"' | fzf --prompt="Select a quality profile: ")
47+
48+
# Check if a selection was made
49+
if [[ -z "$selected_quality_profile" ]]; then
50+
echo "No selection made. Exiting."
51+
exit 1
52+
fi
53+
54+
# Extract both key and language in a single query based on the fzf selection
55+
profile_info=$(echo "$quality_profiles_response" | jq -r --arg selected "$selected_quality_profile" '.profiles[] | select("\(.languageName) (\(.name))" == $selected) | {key, language, name}')
56+
57+
# Extract key and language from the JSON result
58+
selected_quality_profile_name=$(echo "$profile_info" | jq -r '.name')
59+
selected_quality_profile_language=$(echo "$profile_info" | jq -r '.language')
60+
61+
# Display the selected quality profile
62+
echo "You have selected Quality Profile: $selected_quality_profile"
63+
64+
### Step 3: Retrieve and select Quality Gate ###
65+
# Fetch the list of quality gates
66+
quality_gates_response=$(curl -s -X GET "$SONAR_HOST_URL/api/qualitygates/list" \
67+
-H "Authorization: Bearer $SONAR_API_TOKEN")
68+
69+
# Check if the response contains any quality gates
70+
if ! echo "$quality_gates_response" | grep -q '"qualitygates"'; then
71+
echo "Failed to retrieve quality gates. Response:"
72+
echo "$quality_gates_response"
73+
exit 1
74+
fi
75+
76+
# Extract and display the names of the quality gates using jq and fzf for selection
77+
selected_quality_gate=$(echo "$quality_gates_response" | jq -r '.qualitygates[].name' | fzf --prompt="Select a quality gate: ")
78+
79+
# Check if a selection was made
80+
if [[ -z "$selected_quality_gate" ]]; then
81+
echo "No selection made. Exiting."
82+
exit 1
83+
fi
84+
85+
# Extract the ID of the selected quality gate for API usage
86+
selected_quality_gate_name=$(echo "$quality_gates_response" | jq -r --arg selected "$selected_quality_gate" '.qualitygates[] | select(.name == $selected) | .name')
87+
88+
# Display the selected quality gate
89+
echo "You have selected Quality Gate: $selected_quality_gate"
90+
91+
### Step 4: Show summary of selected fields ###
92+
echo ""
93+
echo "########################################"
94+
echo "Project Name: $project_name"
95+
echo "Quality Profile: $selected_quality_profile"
96+
echo "Quality Profile Language: $selected_quality_profile_language"
97+
echo "Quality Gate: $selected_quality_gate"
98+
echo "########################################"
99+
echo ""
100+
101+
# Confirm choices
102+
read -p "Are you sure you want to proceed with these selections? (y/n): " confirmation
103+
104+
if [[ "$confirmation" != "y" ]]; then
105+
echo "Project creation canceled. Exiting."
106+
exit 1
107+
fi
108+
109+
### Step 5: Create the project ###
110+
create_project_response=$(curl -s -X POST "$SONAR_HOST_URL/api/projects/create" \
111+
-H "Authorization: Bearer $SONAR_API_TOKEN" \
112+
-d "name=$project_name&project=$project_name")
113+
114+
if echo "$create_project_response" | grep -q '"errors"'; then
115+
echo "Failed to create project. Response:"
116+
echo "$create_project_response"
117+
exit 1
118+
else
119+
echo "Project $project_name created successfully."
120+
fi
121+
122+
### Step 6: Associate the Quality Profile with the project ###
123+
assign_quality_profile_response=$(curl -s -X POST "$SONAR_HOST_URL/api/qualityprofiles/add_project" \
124+
-H "Authorization: Bearer $SONAR_API_TOKEN" \
125+
-d "project=$project_name&qualityProfile=$selected_quality_profile_name&language=$selected_quality_profile_language")
126+
127+
if echo "$assign_quality_profile_response" | grep -q '"errors"'; then
128+
echo "Failed to assign quality profile. Response:"
129+
echo "$assign_quality_profile_response"
130+
exit 1
131+
else
132+
echo "Quality Profile $selected_quality_profile (Language: $selected_quality_profile_language) assigned to project $project_name successfully."
133+
fi
134+
135+
### Step 7: Assign the Quality Gate to the project ###
136+
assign_quality_gate_response=$(curl -s -X POST "$SONAR_HOST_URL/api/qualitygates/select" \
137+
-H "Authorization: Bearer $SONAR_API_TOKEN" \
138+
-d "projectKey=$project_name&gateName=$selected_quality_gate_name")
139+
140+
if echo "$assign_quality_gate_response" | grep -q '"errors"'; then
141+
echo "Failed to assign quality gate. Response:"
142+
echo "$assign_quality_gate_response"
143+
exit 1
144+
else
145+
echo "Quality Gate $selected_quality_gate assigned to project $project_name successfully."
146+
fi
147+
148+
### Final Confirmation Echo ###
149+
echo ""
150+
echo "########################################"
151+
echo "SUCCESS!"
152+
echo "Project '$project_name' was created successfully."
153+
echo "Quality Profile '$selected_quality_profile' (Language: $selected_quality_profile_language) and Quality Gate '$selected_quality_gate' have been assigned to the project."
154+
echo "########################################"
155+
echo ""

sonar-project.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#----- Project Configuration
2+
# sonar.sources=.
3+
# sonar.projectBaseDir=.
4+
sonar.projectKey=react-native-template
5+
sonar.token=sqp_6d89f6f7ebb165d274df00407c5f6d46df8fe5c0
6+
# sonar.projectVersion=1.0.0

src/app/login.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/components/settings/language-item.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useCallback, useMemo } from 'react';
22

3-
import { translate,useSelectedLanguage } from '@/core';
3+
import { translate, useSelectedLanguage } from '@/core';
44
import type { Language } from '@/core/i18n/resources';
55
import type { OptionType } from '@/ui';
66
import { Options, useModal } from '@/ui';
@@ -15,20 +15,17 @@ export const LanguageItem = () => {
1515
setLanguage(option.value as Language);
1616
modal.dismiss();
1717
},
18-
[setLanguage, modal]
18+
[setLanguage, modal],
1919
);
2020

2121
const langs = useMemo(
22-
() => [
23-
{ label: translate('settings.english'), value: 'en' },
24-
{ label: translate('settings.arabic'), value: 'ar' },
25-
],
26-
[]
22+
() => [{ label: translate('settings.english'), value: 'en' }],
23+
[],
2724
);
2825

2926
const selectedLanguage = useMemo(
3027
() => langs.find((lang) => lang.value === language),
31-
[language, langs]
28+
[language, langs],
3229
);
3330

3431
return (

src/core/i18n/resources.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
import ar from '@/translations/ar.json';
21
import en from '@/translations/en.json';
32

43
export const resources = {
54
en: {
65
translation: en,
76
},
8-
ar: {
9-
translation: ar,
10-
},
117
};
128

139
export type Language = keyof typeof resources;

src/core/i18n/utils.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import i18n from 'i18next';
22
import { initReactI18next } from 'react-i18next';
33

4-
import ar from '../../translations/ar.json';
54
import en from '../../translations/en.json';
65
import { storage } from '../storage';
76
import type { TxKeyPath } from './utils';
8-
import { changeLanguage, getLanguage, translate } from './utils';
7+
import { getLanguage, translate } from './utils';
98

109
jest.mock('../storage', () => ({
1110
storage: {
@@ -26,7 +25,7 @@ i18n.use(initReactI18next).init({
2625
escapeValue: false,
2726
},
2827

29-
resources: { en: { translationsNS: en }, ar: { translationsNS: ar } },
28+
resources: { en: { translationsNS: en } },
3029
});
3130

3231
describe('getLanguage', () => {
@@ -40,12 +39,8 @@ describe('getLanguage', () => {
4039
describe('translate', () => {
4140
it('should return translated string', () => {
4241
const key: TxKeyPath = 'onboarding.message';
43-
let options = { lang: 'en' };
42+
const options = { lang: 'en' };
4443
const translatedString = translate(key, options);
4544
expect(translatedString).toBe('Welcome to rootstrap app site');
46-
changeLanguage('ar');
47-
options = { lang: 'ar' };
48-
const translatedStringArab = translate(key, options);
49-
expect(translatedStringArab).toBe('مرحبا بكم في موقع تطبيق rootstrap');
5045
});
5146
});

src/core/i18n/utils.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type TranslateOptions from 'i18next';
22
import i18n from 'i18next';
33
import memoize from 'lodash.memoize';
44
import { useCallback } from 'react';
5-
import { I18nManager, NativeModules, Platform } from 'react-native';
5+
import { NativeModules, Platform } from 'react-native';
66
import { useMMKVString } from 'react-native-mmkv';
77
import RNRestart from 'react-native-restart';
88

@@ -21,16 +21,11 @@ export const translate = memoize(
2121
(key: TxKeyPath, options = undefined) =>
2222
i18n.t(key, options) as unknown as string,
2323
(key: TxKeyPath, options: typeof TranslateOptions) =>
24-
options ? key + JSON.stringify(options) : key
24+
options ? key + JSON.stringify(options) : key,
2525
);
2626

2727
export const changeLanguage = (lang: Language) => {
2828
i18n.changeLanguage(lang);
29-
if (lang === 'ar') {
30-
I18nManager.forceRTL(true);
31-
} else {
32-
I18nManager.forceRTL(false);
33-
}
3429
if (Platform.OS === 'ios' || Platform.OS === 'android') {
3530
if (__DEV__) {
3631
NativeModules.DevSettings.reload();
@@ -54,7 +49,7 @@ export const useSelectedLanguage = () => {
5449
changeLanguage(lang);
5550
}
5651
},
57-
[setLang]
52+
[setLang],
5853
);
5954

6055
return { language, setLanguage };

src/translations/ar.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)