From 89781b13c274d08157037a3e5f65688dbb63e1e1 Mon Sep 17 00:00:00 2001 From: Hirotaka Mizutani <52546+hirotaka@users.noreply.github.com> Date: Fri, 5 Nov 2021 18:28:53 +0900 Subject: [PATCH 1/3] translate docs/guides/with-svelts --- web/.textlintignore | 1 - web/docs/guides/with-svelte.mdx | 142 ++++++++++++++++---------------- 2 files changed, 71 insertions(+), 72 deletions(-) diff --git a/web/.textlintignore b/web/.textlintignore index 849a095d0..06064a734 100644 --- a/web/.textlintignore +++ b/web/.textlintignore @@ -41,7 +41,6 @@ docs/guides/hosting/docker.mdx docs/guides/hosting/overview.mdx docs/guides/hosting/platform.mdx docs/guides/local-development.mdx -docs/guides/with-svelte.mdx docs/handbook/contributing.mdx docs/handbook/supasquad.mdx docs/learn/auth-deep-dive/google-oauth.md diff --git a/web/docs/guides/with-svelte.mdx b/web/docs/guides/with-svelte.mdx index 528a60e0d..df601787a 100644 --- a/web/docs/guides/with-svelte.mdx +++ b/web/docs/guides/with-svelte.mdx @@ -1,46 +1,46 @@ --- id: with-svelte -title: "Quickstart: Svelte" -description: Learn how to use Supabase in your Svelte App. +title: "クイックスタート:Svelte" +description: SvelteアプリでSupabaseを使用する方法をご紹介します。 --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; -## Intro +## イントロ -This example provides the steps to build a simple user management app (from scratch!) using Supabase and Svelte. It includes: +この例では、SupabaseとSvelteを使って、シンプルなユーザー管理アプリを(ゼロから)構築する手順を紹介します。内容は以下のとおりです。 -- Supabase [Database](/docs/guides/database): a Postgres database for storing your user data. -- Supabase [Auth](/docs/guides/auth): users can sign in with magic links (no passwords, only email). -- Supabase [Storage](/docs/guides/storage): users can upload a photo. -- [Row Level Security](/docs/guides/auth#row-level-security): data is protected so that individuals can only access their own data. -- Instant [APIs](/docs/guides/api): APIs will be automatically generated when you create your database tables. +- Supabase [Database](/docs/guides/database):ユーザーデータを保存するためのPostgresデータベースです。 +- Supabase [Auth](/docs/guides/auth):ユーザーはマジックリンクでサインインできます(パスワードは不要、メールのみ)。 +- Supabase [Storage](/docs/guides/storage):ユーザーは写真をアップロードできます。 +- [行レベルセキュリティー](/docs/guides/auth#row-level-security):データは保護されており、個人が自分のデータにしかアクセスできないようになっています。 +- インスタント[API](/docs/guides/api):データベースのテーブルを作成すると、APIが自動的に生成されます。 -By the end of this guide you'll have an app which allows users to login and update some basic profile details: +このガイドの最後には、ユーザーがログインして基本的なプロフィール情報を更新できるアプリが完成します。 -![Supabase User Management example](/img/user-management-demo.png) +![Supabaseユーザー管理の例](/img/user-management-demo.png) ### Github -Whenever you get stuck at any point, take a look at [this repo](https://github.com/yustarandomname/svelte-supabase-quickstart). +どこかで行き詰ったら、[このリポジトリー](https://github.com/yustarandomname/svelte-supabase-quickstart)を見てみましょう。 -## Project set up +## プロジェクトのセットアップ -Before we start building we're going to set up our Database and API. This is as simple as starting a new Project in Supabase -and then creating a "schema" inside the database. +ビルドを開始する前に、データベースとAPIをセットアップします。Supabaseで新しいプロジェクトを立ち上げ、データベース内に「スキーマ」を作成するだけです。 -### Create a project +### プロジェクトの作成 -1. Go to [app.supabase.io](https://app.supabase.io). -1. Click on "New Project". -1. Enter your project details. -1. Wait for the new database to launch. +1. [app.supabase.io](https://app.supabase.io)にアクセスします。 +1. 「New Project」をクリックします。 +1. プロジェクトの詳細を入力します。 +1. 新しいデータベースが起動するのを待ちます。 -### Set up the database schema +### データベース・スキーマの設定 -Now we are going to set up the database schema. We can use the "User Management Starter" quickstart in the SQL Editor, -or you can just copy/paste the SQL from below and run it yourself. +これからデータベース・スキーマを設定します。SQLエディターの「User Management Starter」クイック・スターターを使用するか、下記のSQLをコピー/ペーストして自分で実行できます。 + + + + ```sh -1. Go to the "SQL" section. -2. Click "User Management Starter". -3. Click "Run". +1. 「SQL」セクションに移動します。 +2. 「User Management Starter」をクリックします。 +3. 「Run」をクリックします。 ``` -### Get the API Keys +### APIキーを取得 -Now that you've created some database tables, you are ready to insert data using the auto-generated API. -We just need to get the URL and `anon` key from the API settings. +データベースのテーブルをいくつか作成したので、自動生成されたAPIを使ってデータを挿入する準備ができました。 +API設定からURLと`anon`キーを取得する必要があります。 ```sh -1. Go to the "Settings" section. -2. Click "API" in the sidebar. -3. Find your API URL in this page. -4. Find your "anon" and "service_role" keys on this page. +1. 「Settings」セクションに移動します。 +2. サイドバーの「API」をリックします。 +3. そのページでAPI URLを探します。 +4. 「anon」と「service_role」キーを探します。 ``` -## Building the App +## アプリの構築 -Let's start building the Svelte app from scratch. +それでは早速、Svelteアプリを一から作ってみましょう。 -### Initialize a Svelte app +### Svelteアプリの初期化 -We can use the [Quickstart Svelte Template](https://svelte.dev/blog/the-easiest-way-to-get-started) to initialize -an app called `supabase-svelte`: +[Svelteテンプレートのクイックスタート](https://svelte.dev/blog/the-easiest-way-to-get-started)を使って、`supbase-svelte`というアプリを初期化します。 ```bash npx degit sveltejs/template supabase-svelte cd supabase-svelte ``` -Then let's install the only additional dependency: [supabase-js](https://github.com/supabase/supabase-js) +そして、唯一追加する必要がある依存関係の[supbase-js](https://github.com/supabase/supabase-js)をインストールしましょう。 ```bash npm install @supabase/supabase-js ``` -And finally we want to save the environment variables in a `.env`. -All we need are the API URL and the `anon` key that you copied [earlier](#get-the-api-keys). +最後に、環境変数を`.env`に保存します。必要なのは、APIのURLと、[先ほど](#apiキーを取得)コピーした`anon`キーだけです。 ```bash title=".env" SVELTE_APP_SUPABASE_URL=YOUR_SUPABASE_URL SVELTE_APP_SUPABASE_ANON_KEY=YOUR_SUPABASE_ANON_KEY ``` -Our app is almost functional, to make svelte work with supabase and .env files we first need to change the `rollup.config.js` file a bit. -Supabase imports `json` files, to convert .json files to ES6 modules we need a the `@rollup/plugin-json` install it by running: +このアプリはほぼ機能していますが、svelteをSupabaseや`.env`ファイルで動作させるためには、まず、`rollup.config.js`ファイルを少し変更する必要があります。 +Supabaseは`json`ファイルをインポートしますが、.jsonファイルをES6モジュールに変換するには、`@rollup/plugin-json`をインストールして実行する必要があります。 ```bash npm install --save-dev @rollup/plugin-json ``` -Furthermore, to use the .env with svelte we need another rollup plugin. Install: +さらに、.envをsvelteで使用するためには、別のrollupプラグインが必要です。そのプラグインをインストールします。 ```bash npm install --save-dev dotenv @rollup/plugin-replace ``` -and add these plugins to the `rollup.config.js` file. +これらのプラグインを`rollup.config.js`ファイルに追加します。 ```js title="rollup.config.js" import { config } from 'dotenv'; @@ -209,8 +209,8 @@ and add these plugins to the `rollup.config.js` file. } ``` -Now that we have the API credentials in place, let's create a helper file to initialize the Supabase client. These variables will be exposed -on the browser, and that's completely fine since we have [Row Level Security](/docs/guides/auth#row-level-security) enabled on our Database. +APIの認証情報が得られたので、次はSupabaseクライアントを初期化するヘルパーファイルを作成しましょう。 +これらの変数はブラウザー上で公開されますが、データベースでは[行レベルのセキュリティ](/docs/guides/auth#row-level-security)が有効になっているので、全く問題ありません。 ```js title="src/supabaseClient.js" import { createClient } from '@supabase/supabase-js' @@ -221,12 +221,12 @@ const supabaseAnonKey = __api.env.SVELTE_APP_SUPABASE_ANON_KEY export const supabase = createClient(supabaseUrl, supabaseAnonKey) ``` -And one optional step is to update the CSS file `public/global.css` to make the app look nice. -You can find the full contents of this file [here](https://raw.githubusercontent.com/supabase/supabase/master/examples/react-user-management/src/index.css). +また、オプションとして、CSSファイルの`public/global.css`を更新して、アプリの外観を整えます。 +[こちら](https://raw.githubusercontent.com/supabase/supabase/master/examples/react-user-management/src/index.css)にあるファイルを参照してください。 -### Set up a Login component +### ログイン・コンポーネントの設定 -Let's set up a Svelte component to manage logins and sign ups. We'll use Magic Links, so users can sign in with their email without using passwords. +ログインとサインアップを管理するSvelteコンポーネントを設定しましょう。マジック・リンクを使用することで、ユーザーはパスワードを使わずにメールでサインインできます。 ```html title="/src/Auth.svelte"