Skip to content

Commit

Permalink
Merge pull request #447 from org-SCAN/doc-sail
Browse files Browse the repository at this point in the history
feat(doc)✨ : complete the sail documentation
  • Loading branch information
lduf authored Nov 27, 2023
2 parents ebbe194 + 3cfffeb commit 2885c82
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,34 @@ Site web du projet :)

# Start the project

## Using SAIL
## Using SAIL (recommended)

To run the project, you must have docker and docker-compose installed on your machine.
To run the project, you must have :
- [Docker](https://docs.docker.com/engine/install/)
- [Composer](https://getcomposer.org/doc/00-intro.md)
- [PHP](https://www.php.net/manual/fr/install.php)

Following the [laravel sail documentation](https://laravel.com/docs/10.x/sail#installing-sail-into-existing-applications.
You need to create a `.env` file in the `src` directory based on the `.env.example` file.
> 💡 When you code you should switch the `APP_DEBUG` to `true` to see the errors.
You can now start Docker and follow the [laravel sail documentation](https://laravel.com/docs/10.x/sail#installing-sail-into-existing-applications)
more specifically the installation part.
Once the installation is done you can run the following command to start the project :

```bash
./vendor/bin/sail up -d #-d to detach the process, you can create an alias for sail later
#Run these in the docker container
npm update
cd /var/www/html
composer update
php artisan cache:clear
composer dump-autoload
php artisan key:generate
chmod -R 777 storage/
php artisan migrate:refresh --seed
```

You can now access the website at [localhost:80](http://localhost:80).


## Using docker
Expand Down
4 changes: 2 additions & 2 deletions src/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ APP_DEBUG=false
APP_URL=

DB_CONNECTION=mysql
DB_HOST=
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=database_name
DB_USERNAME='USER'
Expand Down Expand Up @@ -50,4 +50,4 @@ DEFAULT_PASSWORD="password123"
DEFAULT_TEAM="default_team"

TRANSLATION_API_URL="https://api-free.deepl.com/v2/translate"
TRANSLATION_API_TOKEN="YOUR_API_TOKEN
TRANSLATION_API_TOKEN="YOUR_API_TOKEN"
11 changes: 6 additions & 5 deletions src/app/Models/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,8 @@ public function getLanguageAttribute($value)
public function autoTranslate()
{
foreach (Language::otherLanguages() as $language) {
if(env("TRANSLATION_API_URL") == null || env("TRANSLATION_API_TOKEN") == null){
Translation::handleTranslation(ListControl::find($this->list), $this->field_key, $this->translation, $language->id);
}
else{
// create post request to deepl
// check that the API token and url are set and if not use the default translation
try{
$response = Http::withHeaders([
'Authorization' => "DeepL-Auth-Key " . env("TRANSLATION_API_TOKEN")
])->withBody(http_build_query([
Expand All @@ -73,6 +70,10 @@ public function autoTranslate()
$content = $response->json()["translations"][0]["text"];
Translation::handleTranslation(ListControl::find($this->list), $this->field_key, $content, $language->id);
}
catch(\Exception $e){
// if the translation fails, use the default translation
Translation::handleTranslation(ListControl::find($this->list), $this->field_key, $this->translation, $language->id);
}
}
}

Expand Down

0 comments on commit 2885c82

Please sign in to comment.