Skip to content
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
7 changes: 6 additions & 1 deletion src/lib/i18n/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,19 @@
"password": "Password",
"authenticated": "Authenticated",
"signin": "Sign in",
"login": "Login",
"signout": "Sign out",
"authenticating": "Authenticating...",
"success": "Success",
"failed": "Failed",
"enter_username": "Enter username",
"enter_password": "Enter password",
"status": "Status",
"actions": "Actions"
"actions": "Actions",
"login_to_edit_message": "In order to edit this product, and contribute to food transparency, you need to be logged in to your Open Food Facts account.",
"login_to_create_tags_message": "To create new tags and contribute to food transparency, please log in to your Open Food Facts account",
"login_to_create_tags_tooltip": "Please log in to create new tags and contribute to food transparency",
"create_account": "Create my Open Food Facts account"
},
"general": {
"language": "Language",
Expand Down
9 changes: 6 additions & 3 deletions src/routes/products/[barcode]/Folksonomy.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { preferences } from '$lib/settings';
import { _ } from '$lib/i18n';

import type { FolksonomyKey, FolksonomyTag } from '@openfoodfacts/openfoodfacts-nodejs';
import { createFolksonomyApi, getFolksonomyValues } from '$lib/api/folksonomy';
Expand Down Expand Up @@ -306,7 +307,7 @@
onclick={createNewTag}
disabled={isLoading || !loggedIn}
title={!loggedIn
? 'You must be logged in to create a new tag'
? $_('auth.login_to_create_tags_tooltip')
: isLoading
? 'Creating...'
: undefined}
Expand All @@ -319,8 +320,10 @@
{:else}
<tr>
<td colspan="3" class="text-center">
<p class="mb-4">You must be logged in to create a new tag</p>
<a href="/settings" class="btn btn-primary w-1/4">Login</a>
<p class="mb-4">
{$_('auth.login_to_create_tags_message')}
</p>
<a href="/settings" class="btn btn-primary w-1/4">{$_('auth.login')}</a>
</td>
</tr>
{/if}
Expand Down
9 changes: 7 additions & 2 deletions src/routes/products/[barcode]/edit/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '$lib/api';
import { userInfo } from '$lib/stores/pkceLoginStore';
import { PRODUCT_STATUS } from '$lib/const';
import { _ } from '$lib/i18n';

import type { PageLoad } from './$types';
import { dev } from '$app/environment';
Expand All @@ -29,10 +30,14 @@ export const load: PageLoad = async ({ fetch, params }) => {
// If the user is not logged in, redirect to the login page
// We allow an exception for development mode
error(401, {
message: 'You must be logged in to view this page',
message: get(_)('auth.login_to_edit_message'),
actions: [
{
label: 'Login',
label: get(_)('auth.login'),
url: '/login'
},
{
label: get(_)('auth.create_account'),
url: '/login'
}
]
Expand Down
Loading