Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions group-1/Checkmate/.coderabbit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release_notes: false
6 changes: 6 additions & 0 deletions group-1/Checkmate/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/dist
**/.env
**/*.env
.git
docker/dev/mongo/data
2 changes: 2 additions & 0 deletions group-1/Checkmate/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto
* text eol=lf
1 change: 1 addition & 0 deletions group-1/Checkmate/.github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ajhollid @mohicody @Br0wnHammer @Owaiseimdad @karenvicent @shanikauwu1
15 changes: 15 additions & 0 deletions group-1/Checkmate/.github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username
buy_me_a_coffee: gorkemcetin
thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
31 changes: 31 additions & 0 deletions group-1/Checkmate/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- Browser [e.g. Chrome, Safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions group-1/Checkmate/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
28 changes: 28 additions & 0 deletions group-1/Checkmate/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**(Please remove this line only before submitting your PR. Ensure that all relevant items are checked before submission.)**

## Describe your changes

Briefly describe the changes you made and their purpose.

## Write your issue number after "Fixes "

Fixes #123

## Please ensure all items are checked off before requesting a review. "Checked off" means you need to add an "x" character between brackets so they turn into checkmarks.

- [ ] (Do not skip this or your PR will be closed) I deployed the application locally.
- [ ] (Do not skip this or your PR will be closed) I have performed a self-reviewing and testing of my code.
- [ ] I have included the issue # in the PR.
- [ ] I have added i18n support to visible strings (instead of `<div>Add</div>`, use):

```Javascript
const { t } = useTranslation();
<div>{t('add')}</div>
```

- [ ] I have **not** included any files that are not related to my pull request, including package-lock and package-json if dependencies have not changed
- [ ] I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
- [ ] I made sure font sizes, color choices etc are all referenced from the theme. I don't have any hardcoded dimensions.
- [ ] My PR is granular and targeted to one specific feature.
- [ ] I ran `npm run format` in server and client directories, which automatically formats your code.
- [ ] I took a screenshot or a video and attached to this PR if there is a UI change.
112 changes: 112 additions & 0 deletions group-1/Checkmate/.github/scripts/download-translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import axios from "axios";
import fs from "fs-extra";
import path from "path";
import { URLSearchParams } from "url";

// POEditor API information
const API_TOKEN = process.env.POEDITOR_API;
const PROJECT_ID = process.env.POEDITOR_PROJECT_ID;
const LANGUAGES = (
process.env.LANGUAGES || "ar,zh-tw,cs,en,fi,fr,de,pt-br,ru,es,tr,ja,zh-cn,th"
).split(",");
const EXPORT_FORMAT = process.env.EXPORT_FORMAT || "key_value_json";

// POEditor API endpoint
const API_URL = "https://api.poeditor.com/v2";

function normalizeLanguageCode(language) {
if (language.includes("-")) {
const [base, region] = language.split("-");
return `${base}-${region.toUpperCase()}`;
}
return language;
}

// Function to download translations
async function downloadTranslations() {
try {
console.log("Downloading translations from POEditor...");
console.log(`Using export format: ${EXPORT_FORMAT}`);

for (const language of LANGUAGES) {
console.log(`Downloading translations for ${language} language...`);

// Get export URL from POEditor
const exportResponse = await axios.post(
`${API_URL}/projects/export`,
new URLSearchParams({
api_token: API_TOKEN,
id: PROJECT_ID,
language: language,
type: EXPORT_FORMAT,
})
);

if (exportResponse.data.response.status !== "success") {
throw new Error(
`Failed to get export URL for ${language} language: ${JSON.stringify(
exportResponse.data
)}`
);
}

const fileUrl = exportResponse.data.result.url;
console.log(`Export URL obtained for ${language}`);

// Download translation file
const downloadResponse = await axios.get(fileUrl, {
responseType: "json",
});
const translations = downloadResponse.data;
console.log(`Downloaded translations for ${language}`);

// Check the format of data returned from POEditor and convert if necessary
let formattedTranslations = translations;

// If data is in array format, convert it to key-value format
if (Array.isArray(translations)) {
console.log(
`Converting array format to key-value format for ${language}`
);
formattedTranslations = {};
translations.forEach((item) => {
if (item.term && item.definition) {
formattedTranslations[item.term] = item.definition;
}
});
}

// Determine the output filename based on language
const normalizedLanguage = normalizeLanguageCode(language);
const filename = `${normalizedLanguage}.json`;
const outputPath = path.join(process.cwd(), "temp", filename);
await fs.writeJson(outputPath, formattedTranslations, { spaces: 2 });

console.log(
`Translations for ${language} language successfully downloaded and saved as: ${filename}`
);
}

console.log("All translations successfully downloaded!");
} catch (error) {
console.error("An error occurred while downloading translations:", error);
process.exit(1);
}
}

// Main function
async function main() {
try {
// Clean temp folder
await fs.emptyDir(path.join(process.cwd(), "temp"));

// Download translations
await downloadTranslations();
} catch (error) {
console.error("An error occurred during the process:", error);
process.exit(1);
}
}

// Run script
main();
64 changes: 64 additions & 0 deletions group-1/Checkmate/.github/scripts/upload-translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import axios from "axios";
import FormData from "form-data";
import fs from "fs-extra";

// POEditor API information
const API_TOKEN = process.env.POEDITOR_API;
const PROJECT_ID = process.env.POEDITOR_PROJECT_ID;
const FILE_PATH = process.env.FILE_PATH;
const LANGUAGE = process.env.LANGUAGE;

// POEditor API endpoint
const API_URL = 'https://api.poeditor.com/v2';

// Function to upload translations
async function uploadTranslations() {
try {
console.log(`Uploading translations for ${LANGUAGE} language from ${FILE_PATH}... test1`);

// Check if file exists
if (!await fs.pathExists(FILE_PATH)) {
throw new Error(`File not found: ${FILE_PATH}`);
}

// Read file content
const fileContent = await fs.readFile(FILE_PATH, 'utf8');

// Validate JSON format
try {
JSON.parse(fileContent);
} catch (error) {
throw new Error(`Invalid JSON format in ${FILE_PATH}: ${error.message}`);
}

// Create form data for upload
const formData = new FormData();
formData.append('api_token', API_TOKEN);
formData.append('id', PROJECT_ID);
formData.append('language', LANGUAGE);
formData.append('updating', 'terms_translations');
formData.append('file', fs.createReadStream(FILE_PATH));
formData.append('overwrite', '1');
formData.append('sync_terms', '1');

// Upload to POEditor
const response = await axios.post(`${API_URL}/projects/upload`, formData, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
});

if (response.data.response.status !== 'success') {
throw new Error(`Failed to upload translations: ${JSON.stringify(response.data)}`);
}

console.log(`Successfully uploaded translations for ${LANGUAGE} language.`);
console.log(`Statistics: ${JSON.stringify(response.data.result)}`);
} catch (error) {
console.error('An error occurred while uploading translations:', error);
process.exit(1);
}
}

// Run script
uploadTranslations();
69 changes: 69 additions & 0 deletions group-1/Checkmate/.github/workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# POEditor Translation Synchronization

This GitHub Actions workflow automatically downloads translation files from POEditor and integrates them into the project.

## How It Works

The workflow can be triggered in two ways:

1. **Manual Trigger**: You can manually run the "POEditor Translation Synchronization" workflow from the "Actions" tab in the GitHub interface.
2. **Automatic Trigger**: The workflow runs automatically every day at midnight (UTC).

## Required Settings

For this workflow to function, you need to define the following secrets in your GitHub repository:

1. `POEDITOR_API_TOKEN`: Your POEditor API token
2. `POEDITOR_PROJECT_ID`: Your POEditor project ID

You can add these secrets in the "Settings > Secrets and variables > Actions" section of your GitHub repository.

## Manual Execution

When running the workflow manually, you can specify which languages to download. Languages should be entered as comma-separated values (e.g., `tr,gb,es`).

If you don't specify any languages, the default languages `tr` and `en` will be downloaded.

## Output

When the workflow completes successfully:

1. Translation files for the specified languages are downloaded from POEditor
2. These files are copied to the `src/locales/` directory
3. Changes are automatically committed and pushed to the main branch

## Troubleshooting

If the workflow fails:

1. Check the GitHub Actions logs
2. Make sure your POEditor API token and project ID are correct
3. Ensure that the languages you specified exist in your POEditor project

# POEditor Upload Workflow

## Summary of Implemented Translation Workflow

We have successfully created a GitHub Actions workflow that automatically uploads translation files to POEditor when changes are merged to the develop branch. Here's a summary of what we've implemented:
### Created Files

1. .github/scripts/upload-translations.js

- A Node.js script that handles the upload of translation files to POEditor
- Uses the POEditor API to upload JSON translation files
- Validates file existence and JSON format before uploading
- Provides detailed logging of the upload process

2. .github/workflows/poeditor-upload-on-merge.yml - A GitHub Actions workflow that triggers when PRs are merged to the develop branch - Only runs when changes are made to files in the src/locales directory - Detects which translation files were changed in the PR - Extracts language codes from filenames (e.g., tr.json → "tr") - Calls the upload script for each changed file
### Workflow Process
1. When a PR is merged to the develop branch, the workflow checks if any files in src/locales were modified.

1. If translation files were changed, the workflow:

- Sets up the necessary Node.js environment
- Installs required dependencies
- Identifies which specific translation files were changed
- For each changed file, extracts the language code and uploads to POEditor
- Provides status notifications about the upload process

This automated workflow ensures that your translations are always in sync between your codebase and POEditor, eliminating the need for manual uploads and reducing the risk of translation inconsistencies.
Loading