-
Notifications
You must be signed in to change notification settings - Fork 9
Display blogs in terslated language #10
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
Open
ImTooFastForYou
wants to merge
37
commits into
Telecom-Etude:main
Choose a base branch
from
ImTooFastForYou:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 26 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ffb4dcb
Prise en charge du vocabulaire anglais pour la création de posts
f30b119
Ajout d'une liste déroulante pour la langue d'écriture
ce19789
Traductions en anglais
5a5a785
Modification de la db pour intégrer des échanges entre posts anglais …
5f627d1
Prise en compte de la nouvelle db pour la création d'un post
50c4c0e
Correction du bouton pour changer de langue pour que changer dans lan…
09d41d4
Ajout de la prise en charge du contenu en anglais
f3c7843
Prise en charge de l'anglais pour la création et l'édition de posts
7b2b4f2
Test stricte sur la valeur de locale
b440491
Giga changement permettant de gérer les traductions. Mais ça marche p…
12dfff9
Retablissement de la db initiale en ajoutant cette fois ci un slugtr …
5dc1f46
db changée mais osef
f6634db
Mise en place de l'ajout d'un post en vue d'être traduit lors de la c…
26ee5c4
Prise en charge de la redirection vers le post traduit
8f9aac7
Menage du spaghetti code que j'avais ajouté
5dfc006
Api qui ne sert plus à rien du coup (je sais même pas d'où sort get-l…
29bc8ba
Merge branch 'Telecom-Etude:main' into main
ImTooFastForYou 7a2d0b3
Fixé l'affichage des noms sur les posts
2c66e01
Fixed format
785efb4
Fixed types and format
56b8e5c
Fixed the locale use to avoid usePathname()
afd3ea4
Fixed useless modification
6a7bf75
Removed useless imports
5241150
Fixed useless modification
f45fabb
"translated" semble plus approprié
709df19
Code pour update la db. Attention à son utilisation si des posts exis…
9e183b8
Renamed the file
d045d75
Used last elements instead of pop/push
a16bd05
Got rid of useless db
cbc7742
Modified it to generate the new column and fixed minor issues
ccd94d7
Made slugtr not mandatory
e865d2e
Prettier format fixes
89011a7
Modified PostPresentation to change slugtr to a string | null type
4d01705
Tests pour m'assurer que les migrations et l'ajout de slugtr marchent…
efb7571
Removed the ? to make slugtr non undefined
05d797b
Added a test on locale to make a difference in the slugs.
121c6c0
Used constants
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| Warnings: | ||
|
|
||
| - You are about to drop the column `slug` on the `Post` table. All the data in the column will be lost. | ||
| - You are about to drop the column `title` on the `Post` table. All the data in the column will be lost. | ||
| - Added the required column `slugen` to the `Post` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `slugfr` to the `Post` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `titleen` to the `Post` table without a default value. This is not possible if the table is not empty. | ||
| - Added the required column `titlefr` to the `Post` table without a default value. This is not possible if the table is not empty. | ||
|
|
||
| */ | ||
| -- RedefineTables | ||
| PRAGMA defer_foreign_keys=ON; | ||
| PRAGMA foreign_keys=OFF; | ||
| CREATE TABLE "new_Post" ( | ||
| "id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, | ||
| "titlefr" TEXT NOT NULL, | ||
| "titleen" TEXT NOT NULL, | ||
| "locale" TEXT NOT NULL, | ||
| "slugfr" TEXT NOT NULL, | ||
| "slugen" TEXT NOT NULL, | ||
| "content" TEXT NOT NULL, | ||
| "validated" BOOLEAN NOT NULL DEFAULT false, | ||
| "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
| "updatedAt" DATETIME NOT NULL | ||
| ); | ||
| INSERT INTO "new_Post" ("content", "createdAt", "id", "locale", "updatedAt", "validated") SELECT "content", "createdAt", "id", "locale", "updatedAt", "validated" FROM "Post"; | ||
| DROP TABLE "Post"; | ||
| ALTER TABLE "new_Post" RENAME TO "Post"; | ||
| CREATE UNIQUE INDEX "Post_id_key" ON "Post"("id"); | ||
| CREATE UNIQUE INDEX "Post_slugfr_key" ON "Post"("slugfr"); | ||
| CREATE UNIQUE INDEX "Post_slugen_key" ON "Post"("slugen"); | ||
| PRAGMA foreign_keys=ON; | ||
| PRAGMA defer_foreign_keys=OFF; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| -- This is an empty migration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. choose better name, like "add-slugtr.ts"
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import { PrismaClient } from "@prisma/client"; | ||
|
|
||
| const prisma = new PrismaClient(); | ||
|
|
||
| async function updateSlugTr() { | ||
| await prisma.post.updateMany({ | ||
| where: { | ||
| locale: "fr", | ||
| }, | ||
| data: { | ||
| slugtr: { | ||
| set: await prisma.$queryRaw`CONCAT(title, '_not_translated')`, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| await prisma.post.updateMany({ | ||
| where: { | ||
| locale: "en", | ||
| }, | ||
| data: { | ||
| slugtr: { | ||
| set: await prisma.$queryRaw`CONCAT(title, '_not_translated')`, | ||
| }, | ||
| }, | ||
| }); | ||
| // Cette partie ne devrait pas être incluse si les posts ont une version en français et en anglais car ces derniers seraient dupliqués. | ||
| const posts = await prisma.post.findMany({ | ||
| include: { | ||
| authors: true, | ||
| labels: true, | ||
| }, | ||
| }); | ||
|
|
||
| for (const post of posts) { | ||
| const newLocale = post.locale === "fr" ? "en" : "fr"; | ||
|
|
||
| await prisma.post.create({ | ||
| data: { | ||
| title: post.title + "_not_translated", | ||
| locale: newLocale, | ||
| slugtr: post.slugtr, | ||
| slug: post.slug, | ||
| authors: { | ||
| connect: post.authors.map(author => ({ id: author.id })), | ||
| }, | ||
| content: "", | ||
| validated: false, | ||
| labels: { | ||
| connect: post.labels.map(label => ({ id: label.id })), | ||
| }, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| updateSlugTr() | ||
| .then(() => { | ||
| console.log("Mise à jour terminée"); | ||
| prisma.$disconnect(); | ||
| }) | ||
| .catch(error => { | ||
| console.error("Erreur :", error); | ||
| prisma.$disconnect(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.