Skip to content

Commit

Permalink
اضافه کردن ویژگی چندزبانه
Browse files Browse the repository at this point in the history
  • Loading branch information
ircfspace committed Feb 2, 2024
1 parent fcb10a0 commit dae241d
Show file tree
Hide file tree
Showing 8 changed files with 188 additions and 55 deletions.
44 changes: 44 additions & 0 deletions assets/css/lang.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
html[lang="en"] body {
direction: ltr;
text-align: left;
}

.flags {
float: left;
margin: 10px 0 -10px 0;
}
html[lang="en"] .flags {
float: right;
}
html[lang="en"] nav,
html[lang="en"] .nav,
html[lang="en"] footer {
direction: rtl;
}
.flags li {
float: left;
list-style: none;
margin-right: 3px;
}
.flags li a {
float: left;
border: 3px solid transparent;
}
.flags li a.active {
border-color: #ccc;
}
.flags li img {
float: left;
width: 25px;
height: 15px;
object-fit: cover;
}

html[lang="en"] .fetchIps button:first-child {
border-radius: 5px 0 0 5px;
}
html[lang="en"] .fetchIps button:last-child {
border-radius: 0 5px 5px 0;
border-right: 1px solid #adadad;
border-left: inherit;
}
6 changes: 3 additions & 3 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ img[alt="loader"] {
width: 50%;
}
.fetchIps button:first-child {
width: calc(100% - 100px);
width: calc(100% - 130px);
border-radius: 0 5px 5px 0;
}
.fetchIps button:last-child {
width: 100px;
width: 130px;
border-radius: 5px 0 0 5px;
border-right: transparent;
}
Expand Down Expand Up @@ -432,4 +432,4 @@ footer p {
margin-top: 10px;
height: 70px;
}
}
}
Binary file added assets/img/flag/gb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/flag/ir.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions assets/js/lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function updateContent(langData) {
document.querySelectorAll('[data-i18n]').forEach(element => {
const key = element.getAttribute('data-i18n');
if (key) {
element.textContent = langData[key];
}
});
document.querySelectorAll('[data-i18n-label]').forEach(element => {
const label = element.getAttribute('data-i18n-label');
if (label) {
element.placeholder = langData[label];
}
});
}

function setLanguagePreference(lang) {
localStorage.setItem('language', lang);
//location.reload();
}

async function fetchLanguageData(lang) {
const response = await fetch("assets/lang/"+lang+".json");
return response.json();
}

async function changeLanguage(lang) {
await setLanguagePreference(lang);
const langData = await fetchLanguageData(lang);
updateContent(langData);
$('#flags li [data-lang]').removeClass('active');
$('#flags li [data-lang="'+lang+'"]').addClass('active');
$('html').attr('lang', lang);
//toggleArabicStylesheet(lang); // Toggle Arabic stylesheet
}

window.addEventListener('DOMContentLoaded', async () => {
const userPreferredLanguage = localStorage.getItem('language') || 'fa';
$('#flags li [data-lang]').removeClass('active');
$('#flags li [data-lang="'+userPreferredLanguage+'"]').addClass('active');
$('html').attr('lang', userPreferredLanguage);
console.log(userPreferredLanguage)
const langData = await fetchLanguageData(userPreferredLanguage);
updateContent(langData);
//toggleArabicStylesheet(userPreferredLanguage);
});

$(document).on('click', 'a[data-lang]', function(e) {
e.preventDefault();
let lang = $(this).data('lang');
changeLanguage(lang);
});
26 changes: 26 additions & 0 deletions assets/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"welcome_message": "Using the Fragment tool, you can revive your dead domains!",
"config_input": "Provide a VLESS/VMESS configuration with WS type:",
"config_input_label": "Your Config",
"config_input_submit": "Check",
"config_form_ortext": "OR",
"config_form_label": "Manually complete the following settings:",
"config_form_protocol": "Protocol",
"config_form_uuid": "UUID",
"config_form_port": "PORT",
"config_form_cleanip": "CleanIP (default: zula.ir)",
"config_form_sni": "SNI",
"config_form_path": "PATH",
"config_form_submit": "Create a JSON file",
"config_form_copy": "Copy Code",
"config_swith_tls": "TLS",
"config_swith_insecure": "Insecure",
"config_swith_earlydata": "Early Data",
"config_swith_mux": "Mux",
"config_mux_label": "the value of Concurrency",
"config_mux_concurrency": "Concurrency",
"config_fragment_label": "the values for Fragments",
"config_fragment_packets": "Packets",
"config_fragment_length": "Length",
"config_fragment_interval": "Interval"
}
26 changes: 26 additions & 0 deletions assets/lang/fa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"welcome_message": "توسط ابزار فرگمنت می‌تونین دامنه‌های مرده‌تون رو مجدد زنده کنید!",
"config_input": "یک کانفیگ VLESS/VMESS از نوع webSocket وارد کنین:",
"config_input_label": "Your Config",
"config_input_submit": "بررسی",
"config_form_ortext": "یا",
"config_form_label": "تنظیمات زیر رو به‌صورت دستی تکمیل کنین:",
"config_form_protocol": "پروتکل",
"config_form_uuid": "UUID",
"config_form_port": "PORT",
"config_form_cleanip": "CleanIP (default: zula.ir)",
"config_form_sni": "SNI",
"config_form_path": "PATH",
"config_form_submit": "ایجاد فایل JSON",
"config_form_copy": "کپی کد",
"config_swith_tls": "TLS",
"config_swith_insecure": "Insecure",
"config_swith_earlydata": "Early Data",
"config_swith_mux": "Mux",
"config_mux_label": "مقدار Concurrency",
"config_mux_concurrency": "concurrency",
"config_fragment_label": "مقادیر فرگمنت",
"config_fragment_packets": "Packets",
"config_fragment_length": "Length",
"config_fragment_interval": "Interval"
}
90 changes: 38 additions & 52 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<link href="./assets/css/bootstrap.min.css" rel="stylesheet" />
<link href="./assets/css/bootstrap-rtl.min.css" rel="stylesheet" />
<link href="./assets/css/vazir.css" rel="stylesheet" />
<link href="./assets/css/style.css?v1.7" rel="stylesheet" />
<link href="./assets/css/style.css?v1.8" rel="stylesheet" />
<link href="./assets/css/lang.css?v1.0" rel="stylesheet" />
<title>IRCF | ابزار فرگمنت</title>
<meta name="description" content="آی پی سالم و تمیز برای کلودفلر (کلادفلر) جهت دسترسی به اینترنت آزاد" />
<meta name="keywords" content="کلودفلر, کلادفلر, cloudflare, cf, آی پی تمیز, آی پی سالم, اسکن آی پی" />
Expand Down Expand Up @@ -53,92 +54,76 @@ <h1>اینترنت برای همه؛ یا هیچ‌کس!</h1>
</li>
</ul>
<div class="clearfix"></div>
<ul class="flags" id="flags">
<li><a href="index.html" data-lang="en">
<img src="assets/img/flag/gb.png" alt="EN / انگلیسی" />
</a></li>
<li><a href="index.html" data-lang="fa">
<img src="assets/img/flag/ir.png" alt="FA / پارسی" />
</a></li>
</ul>
<div class="clearfix"></div>
<div class="alert alert-info" id="defAlert">
<p>توسط ابزار فرگمنت می‌تونین دامنه‌های مرده‌تون رو مجدد زنده کنید!</p>
<p data-i18n="welcome_message"></p>
</div>
<p>یک کانفیگ VLESS/VMESS از نوع webSocket وارد کنین:</p>
<p data-i18n="config_input"></p>
<div class="input-group">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="checkConf">بررسی</button>
<button class="btn btn-default" type="button" id="checkConf" data-i18n="config_input_submit"></button>
</span>
<input class="form-control dirLeft" placeholder="Your Config" value="" id="defConfig" />
<input class="form-control dirLeft" data-i18n-label="config_input_label" value="" id="defConfig" />
</div>
<div class="orClass"><small>یا</small></div>
<p>یا تنظیمات زیر رو به‌صورت دستی تکمیل کنین:</p>
<div class="orClass"><small data-i18n="config_form_ortext"></small></div>
<p data-i18n="config_form_label"></p>
<div class="xsWidth withSmallCenter">
<select class="form-control dirLeft" id="protocol">
<option value="vless">VLESS (WS)</option>
<option value="vmess">VMESS (WS)</option>
</select>
<input class="form-control dirLeft" placeholder="UUID" id="uuid" />
<input class="form-control dirLeft" placeholder="PORT" id="port" type="number" min="0" />
<input class="form-control dirLeft" data-i18n-label="config_form_uuid" id="uuid" />
<input class="form-control dirLeft" data-i18n-label="config_form_port" id="port" type="number" min="0" />
</div>
<div class="xsWidth">
<input class="form-control dirLeft" placeholder="CleanIP (default: zula.ir)" id="cleanIp" />
<input class="form-control dirLeft" placeholder="SNI" id="sni" />
<input class="form-control dirLeft" placeholder="PATH" id="path" />
<input class="form-control dirLeft" data-i18n-label="config_form_cleanip" id="cleanIp" />
<input class="form-control dirLeft" data-i18n-label="config_form_sni" id="sni" />
<input class="form-control dirLeft" data-i18n-label="config_form_path" id="path" />
</div>
<div class="clearfix"></div>
<label class="switch">
<input type="checkbox" id="tls" checked />
<span class="slider round"></span>
<strong>TLS</strong>
<strong data-i18n="config_swith_tls"></strong>
</label>
<label class="switch">
<input type="checkbox" id="insecure" checked />
<span class="slider round"></span>
<strong id="secureLabel" title="Allow Insecure">Insecure</strong>
<strong id="secureLabel" title="Allow Insecure" data-i18n="config_swith_insecure"></strong>
</label>
<label class="switch">
<input type="checkbox" id="early" />
<span class="slider round"></span>
<strong>Early Data</strong>
<strong data-i18n="config_swith_earlydata"></strong>
</label>
<label class="switch">
<input type="checkbox" id="mux" />
<span class="slider round"></span>
<strong>Mux</strong>
<strong data-i18n="config_swith_mux"></strong>
</label>
<div class="orClass"><small>مقادیر فرگمنت</small></div>
<div class="orClass"><small data-i18n="config_fragment_label"></small></div>
<div class="xsWidth">
<input class="form-control dirLeft" placeholder="Packets" title="Packets" id="packets" value="tlshello" />
<input class="form-control dirLeft" placeholder="Length" title="Length" id="length" value="10-20" />
<input class="form-control dirLeft" placeholder="Interval" title="Interval" id="interval" value="10-20" />
<input class="form-control dirLeft" data-i18n-label="config_fragment_packets" title="Packets" id="packets" value="tlshello" />
<input class="form-control dirLeft" data-i18n-label="config_fragment_length" title="Length" id="length" value="10-20" />
<input class="form-control dirLeft" data-i18n-label="config_fragment_interval" title="Interval" id="interval" value="10-20" />
</div>
<div class="muxForm none" id="muxForm">
<div class="orClass"><small>مقدار Concurrency</small></div>
<input class="form-control dirLeft" placeholder="Concurrency" id="concurrency" value="8" />
<div class="orClass"><small data-i18n="config_mux_label"></small></div>
<input class="form-control dirLeft" data-i18n-label="config_mux_concurrency" id="concurrency" value="8" />
</div>
<div class="input-group fetchIps">
<button class="btn btn-info" type="submit" id="getFile">
ایجاد فایل JSON
</button>
<button class="btn btn-default active" id="copyCode">
کپی کد
</button>
<button class="btn btn-info" type="submit" id="getFile" data-i18n="config_form_submit"></button>
<button class="btn btn-default active" id="copyCode" data-i18n="config_form_copy"></button>
</div>
<div class="clearfix"></div>
<div id="tableResults" class="hidden">
<div class="clearfix"></div>
<hr>
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>#</th>
<th>آی‌پی</th>
<th>عملیات</th>
</tr>
</thead>
<tbody id="result"></tbody>
</table>
</div>
<div id="list">
<div class="clearfix"></div>
<hr>
<textarea class="form-control dirLeft"></textarea>
</div>
</div>
<br>
<div id="donate" class="modal fade" role="dialog">
<div class="modal-dialog modal-sm">
Expand Down Expand Up @@ -191,12 +176,13 @@ <h4 class="modal-title">دونیت</h4>
با کمک
GFW-knocker
</p>
<!--<div class="text-center">
<div class="text-center hidden">
<a href="#" class="btn btn-link btn-normal btn-lg btn-outline donateLink" data-toggle="modal" data-target="#donate"></a>
</div>-->
</div>
<script src="./assets/js/jquery.min.js"></script>
<script src="./assets/js/bootstrap.min.js"></script>
<script src="./assets/js/script.js?v1.7.3"></script>
<script src="./assets/js/lang.js?v1.0"></script>
<script src="./assets/js/script.js?v1.8"></script>
</footer>
</div>
</div>
Expand Down

0 comments on commit dae241d

Please sign in to comment.