Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add arabic language + switch LTR or RTL #599

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/app/modules/pia/export/export.component.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@import '~src/assets/stylesheets/variables';
@import "~src/assets/stylesheets/variables";
.pia-exportBlock {

&-title {
padding-bottom: 5px;;
padding-bottom: 5px;
margin-bottom: 15px;
color: $pia-gray;
border-bottom: 2px solid $pia-gray;
Expand Down Expand Up @@ -58,15 +57,15 @@
margin-top: 4px;
}
span {
transition: all .3s;
transition: all 0.3s;
margin-left: 27px;
display: block;
}
}
}
button {
cursor: pointer;
margin-top:10px;
margin-top: 10px;
width: 100%;
padding: 10px 0;
text-align: center;
Expand All @@ -92,7 +91,8 @@
/* Custom checkboxes styles */
input {
position: absolute;
left: -9999px;
visibility: hidden;
left: 0;
}
label {
cursor: pointer;
Expand All @@ -109,14 +109,14 @@
}
}
label::before {
content: '';
content: "";
display: block;
position: absolute;
top: 3px;
width: 16px;
height: 16px;
border: 1px solid $pia-gray-dark;
transition: all .3s;
transition: all 0.3s;
}
input:checked + label::before {
background-color: $pia-green;
Expand Down
20 changes: 19 additions & 1 deletion src/app/services/languages.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class LanguagesService {
*/
initLanguages(): void {
this.translateService.addLangs([
'ar',
'bg',
'cz',
'de',
Expand Down Expand Up @@ -51,13 +52,14 @@ export class LanguagesService {
// Set default language
const browserLang = this.translateService.getBrowserLang();
language = browserLang.match(
/bg|cz|de|dk|el|en|es|et|fi|fr|hr|hu|it|lt|lv|nl|no|pl|pt|ro|sl|sv/
/ar|bg|cz|de|dk|el|en|es|et|fi|fr|hr|hu|it|lt|lv|nl|no|pl|pt|ro|sl|sv/
)
? browserLang
: 'fr';
this.translateService.use(language);
}
this.selectedLanguage = language;
this.useAdequateDirection(this.selectedLanguage);
}

/**
Expand All @@ -68,5 +70,21 @@ export class LanguagesService {
localStorage.setItem('userLanguage', selectedLanguage);
this.translateService.use(selectedLanguage);
this.selectedLanguage = selectedLanguage;
this.useAdequateDirection(this.selectedLanguage);
}

/**
* Use LTR or RTL direction according to current language
* @param selectedLanguage
*/
useAdequateDirection(selectedLanguage: string): void {
const htmlElement = document.getElementById('htmlElement');
if (htmlElement) {
if (selectedLanguage == 'ar') {
htmlElement.setAttribute('dir', 'rtl');
} else {
htmlElement.setAttribute('dir', 'ltr');
}
}
}
}
12 changes: 12 additions & 0 deletions src/app/shared/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,18 @@
{{ "header.languages.bg" | translate }}
</a>
</li>
<li
[ngClass]="{
is_active: languagesService.selectedLanguage === 'ar'
}"
>
<a
href="javascript:;"
(click)="languagesService.updateCurrentLanguage('ar')"
>
{{ "header.languages.ar" | translate }}
</a>
</li>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" id="htmlElement">
<head>
<meta charset="utf-8" />
<title>PIA - Privacy Impact Assessment</title>
Expand Down