feat: i18n

This commit is contained in:
André Glatzl committed 2020-11-13 12:18:08 +01:00
1 parent 7bdcba46b8
commit aa7dedb114
23 files changed
+2660 -1807

No files matched your search

+2
View File
@@ -60,3 +60,5 @@ SMTP_REPLY_EMAIL=
# Custom logo that displays on the authentication screen, scaled to height: 60px
# TEAM_LOGO=https://example.com/images/logo.png
DEFAULT_LANGUAGE=en_US
+1
View File
@@ -5,6 +5,7 @@ import BaseModel from "./BaseModel";
class Team extends BaseModel {
id: string;
name: string;
language: string;
avatarUrl: string;
slackConnected: boolean;
googleConnected: boolean;
+6 -5
View File
@@ -3,6 +3,7 @@ import { observer, inject } from "mobx-react";
import * as React from "react";
import { Switch, Route } from "react-router-dom";
import { t } from "shared/translations/i18n";
import AuthStore from "stores/AuthStore";
import DocumentsStore from "stores/DocumentsStore";
import Actions, { Action } from "components/Actions";
@@ -28,16 +29,16 @@ class Dashboard extends React.Component<Props> {
return (
<CenteredContent>
<PageTitle title="Home" />
<h1>Home</h1>
<PageTitle title={t("Home")} />
<h1>{t("Home")}</h1>
<Tabs>
<Tab to="/home" exact>
Recently updated
{t("Recently updated")}
</Tab>
<Tab to="/home/recent" exact>
Recently viewed
{t("Recently viewed")}
</Tab>
<Tab to="/home/created">Created by me</Tab>
<Tab to="/home/created">{t("Created by me")}</Tab>
</Tabs>
<Switch>
<Route path="/home/recent">
+18
View File
@@ -11,6 +11,7 @@ import CenteredContent from "components/CenteredContent";
import Flex from "components/Flex";
import HelpText from "components/HelpText";
import Input, { LabelText } from "components/Input";
import InputSelect from "components/InputSelect";
import PageTitle from "components/PageTitle";
import ImageUpload from "./components/ImageUpload";
import env from "env";
@@ -26,6 +27,7 @@ class Details extends React.Component<Props> {
form: ?HTMLFormElement;
@observable name: string;
@observable language: string;
@observable subdomain: ?string;
@observable avatarUrl: ?string;
@@ -33,6 +35,7 @@ class Details extends React.Component<Props> {
const { team } = this.props.auth;
if (team) {
this.name = team.name;
this.language = team.language;
this.subdomain = team.subdomain;
}
}
@@ -49,6 +52,7 @@ class Details extends React.Component<Props> {
try {
await this.props.auth.updateTeam({
name: this.name,
language: this.language,
avatarUrl: this.avatarUrl,
subdomain: this.subdomain,
});
@@ -62,6 +66,10 @@ class Details extends React.Component<Props> {
this.name = ev.target.value;
};
handleLanguageChange = (ev: SyntheticInputEvent<*>) => {
this.language = ev.target.value;
};
handleSubdomainChange = (ev: SyntheticInputEvent<*>) => {
this.subdomain = ev.target.value.toLowerCase();
};
@@ -119,6 +127,16 @@ class Details extends React.Component<Props> {
required
short
/>
<InputSelect
label="Language"
options={[
{ label: "English (US)", value: "en_US" },
{ label: "German (Germany)", value: "de_DE" },
]}
value={this.language}
onChange={this.handleLanguageChange}
short
/>
{env.SUBDOMAINS_ENABLED && (
<>
<Input
+3
View File
@@ -2,6 +2,7 @@
import invariant from "invariant";
import { observable, action, computed, autorun, runInAction } from "mobx";
import { getCookie, setCookie, removeCookie } from "tiny-cookie";
import { i18n } from "shared/translations/i18n";
import RootStore from "stores/RootStore";
import Team from "models/Team";
import User from "models/User";
@@ -125,6 +126,8 @@ export default class AuthStore {
this.user = new User(user);
this.team = new Team(team);
i18n.changeLanguage(this.team.language);
if (window.Sentry) {
window.Sentry.configureScope(function (scope) {
scope.setUser({ id: user.id });
+83
View File
@@ -0,0 +1,83 @@
module.exports = {
contextSeparator: '_',
// Key separator used in your translation keys
createOldCatalogs: false,
// Save the \_old files
defaultNamespace: 'translation',
// Default namespace used in your i18next config
defaultValue: '',
// Default value to give to empty keys
indentation: 2,
// Indentation of the catalog files
keepRemoved: false,
// Keep keys from the catalog that are no longer in code
keySeparator: '$',
// Key separator used in your translation keys
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
// see below for more details
lexers: {
hbs: ['HandlebarsLexer'],
handlebars: ['HandlebarsLexer'],
htm: ['HTMLLexer'],
html: ['HTMLLexer'],
mjs: ['JavascriptLexer'],
js: ['JavascriptLexer'], // if you're writing jsx inside .js files, change this to JsxLexer
ts: ['JavascriptLexer'],
jsx: ['JsxLexer'],
tsx: ['JsxLexer'],
default: ['JavascriptLexer']
},
lineEnding: 'auto',
// Control the line ending. See options at https://github.com/ryanve/eol
namespaceSeparator: ':',
// Namespace separator used in your translation keys
// If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance.
output: 'shared/translations/default.json',
// Supports $LOCALE and $NAMESPACE injection
// Supports JSON (.json) and YAML (.yml) file formats
// Where to write the locale files relative to process.cwd()
input: undefined,
// An array of globs that describe where to look for source files
// relative to the location of the configuration file
sort: false,
// Whether or not to sort the catalog
skipDefaultValues: false,
// Whether to ignore default values.
useKeysAsDefaultValue: true,
// Whether to use the keys as the default value; ex. "Hello": "Hello", "World": "World"
// This option takes precedence over the `defaultValue` and `skipDefaultValues` options
verbose: false,
// Display info about the parsing including some stats
failOnWarnings: false,
// Exit with an exit code of 1 on warnings
customValueTemplate: null
// If you wish to customize the value output the value as an object, you can set your own format.
// ${defaultValue} is the default value you set in your translation function.
// Any other custom property will be automatically extracted.
//
// Example:
// {
// message: "${defaultValue}",
// description: "${maxLength}", // t('my-key', {maxLength: 150})
// }
}
+5 -1
View File
@@ -5,11 +5,12 @@
"main": "index.js",
"scripts": {
"clean": "rimraf build",
"build:i18n": "i18next 'app/**/*.js' 'server/**/*.js' ",
"build:server": "babel -d ./build/server ./server && babel -d ./build/shared ./shared && cp package.json ./build && ln -sf \"$(pwd)/webpack.config.dev.js\" ./build",
"build:webpack": "webpack --config webpack.config.prod.js",
"build": "yarn clean && yarn build:webpack && yarn build:server",
"start": "node ./build/server/index.js",
"dev": "nodemon --exec \"yarn build:server && node build/server/index.js\" -e js --ignore build/ --ignore app/",
"dev": "nodemon --exec \"yarn build:server && cp -R shared/translations/*.json build/shared/translations && node build/server/index.js\" -e js --ignore build/ --ignore app/",
"lint": "eslint app server shared",
"flow": "flow",
"deploy": "git push heroku master",
@@ -92,6 +93,7 @@
"fs-extra": "^4.0.2",
"google-auth-library": "^5.5.1",
"http-errors": "1.4.0",
"i18next": "^19.8.3",
"immutable": "^3.8.2",
"imports-loader": "0.6.5",
"invariant": "^2.2.2",
@@ -137,6 +139,7 @@
"react-dom": "^16.8.6",
"react-dropzone": "4.2.1",
"react-helmet": "^5.2.0",
"react-i18next": "^11.7.3",
"react-keydown": "^1.7.3",
"react-modal": "^3.1.2",
"react-portal": "^4.0.0",
@@ -182,6 +185,7 @@
"eslint-plugin-react-hooks": "^4.1.0",
"fetch-test-server": "^1.1.0",
"flow-bin": "^0.104.0",
"i18next-parser": "^3.3.0",
"html-webpack-plugin": "3.2.0",
"jest-cli": "^26.0.0",
"koa-webpack-dev-middleware": "^1.4.5",
+2
View File
@@ -12,6 +12,7 @@ const router = new Router();
router.post("team.update", auth(), async (ctx) => {
const {
name,
language,
avatarUrl,
subdomain,
sharing,
@@ -27,6 +28,7 @@ router.post("team.update", auth(), async (ctx) => {
}
if (name) team.name = name;
if (language) team.language = language;
if (sharing !== undefined) team.sharing = sharing;
if (documentEmbeds !== undefined) team.documentEmbeds = documentEmbeds;
if (guestSignin !== undefined) team.guestSignin = guestSignin;
+14
View File
@@ -0,0 +1,14 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn('teams', 'language', {
type: Sequelize.STRING,
defaultValue: process.env.DEFAULT_LANGUAGE,
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.removeColumn('teams', 'language');
}
};
+15 -7
View File
@@ -4,6 +4,7 @@ import path from "path";
import { URL } from "url";
import util from "util";
import uuid from "uuid";
import { t } from "../../shared/translations/i18n";
import {
stripSubdomain,
RESERVED_SUBDOMAINS,
@@ -27,6 +28,10 @@ const Team = sequelize.define(
primaryKey: true,
},
name: DataTypes.STRING,
language: {
type: DataTypes.STRING,
defaultValue: process.env.DEFAULT_LANGUAGE,
},
subdomain: {
type: DataTypes.STRING,
allowNull: true,
@@ -139,9 +144,11 @@ Team.prototype.provisionSubdomain = async function (subdomain) {
Team.prototype.provisionFirstCollection = async function (userId) {
const collection = await Collection.create({
name: "Welcome",
description:
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!",
name: t("Welcome"),
description: t(
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!"
),
type: "atlas",
teamId: this.id,
creatorId: userId,
});
@@ -149,10 +156,10 @@ Team.prototype.provisionFirstCollection = async function (userId) {
// For the first collection we go ahead and create some intitial documents to get
// the team started. You can edit these in /server/onboarding/x.md
const onboardingDocs = [
"Support",
"Integrations & API",
"Our Editor",
"What is Outline",
t("Support"),
t("Integrations & API"),
t("Our Editor"),
t("What is Outline"),
];
for (const title of onboardingDocs) {
const text = await readFile(
@@ -163,6 +170,7 @@ Team.prototype.provisionFirstCollection = async function (userId) {
"..",
"server",
"onboarding",
process.env.DEFAULT_LANGUAGE,
`${title}.md`
),
"utf8"
File renamed without changes.
+24
View File
@@ -0,0 +1,24 @@
Das Herzstück von Outline ist der Dokumenteditor. Wir lassen Sie nach Belieben schreiben - sei es Markdown, WYSIWYG oder die vielen Tastenkombinationen.
## Abschrift
Wenn Sie mit dem Schreiben von Markdowns vertraut sind, werden alle gewohnten Verknüpfungen unterstützt. Geben Sie beispielsweise \ * \ * fett \ * \ * ein, um sofort fett gedruckten Text zu erstellen. Wenn Sie eine Syntax vergessen haben oder nach einer kurzen Auffrischung auf das Tastatursymbol in der unteren rechten Ecke klicken, um unsere Anleitung zu erhalten. Wenn Sie einige der wichtigsten Markdown-Verknüpfungen kennenlernen, wird die Verwendung von Outline schneller und angenehmer!
! [Die Formatierungssymbolleiste] (/ images / Screenshots / formatating-toolbar.png)
:::die Info
Sie können Markdown oder HTML auch von einer anderen Stelle direkt in ein Dokument einfügen.
:::
## Reichhaltige Dokumente
Der Editor unterstützt eine Vielzahl von Inhaltsblöcken, darunter Bilder, Tabellen, Listen, Zitate, Videos und mehr. Geben Sie "/" in eine leere Zeile ein oder klicken Sie auf das Symbol "+", um das Menü zum Einfügen von Blöcken auszulösen. Sie können weiter tippen, um es herauszufiltern.
Sie können Bilder auch ziehen und ablegen, um sie in Ihr Dokument aufzunehmen, oder einen Link einfügen, um Inhalte aus einer der vielen unterstützten [Integrationen] einzubetten (https://www.getoutline.com/integrations).
! [Das Blockmenü] (/ images / reviewshots / block-menu.png)
## Verweise
Durch das Verknüpfen mit einem anderen Dokument werden automatisch Backlinks erstellt, die auf dem neuesten Stand gehalten und am unteren Rand des Dokuments angezeigt werden. Sie können also eine Bibliothek mit verknüpften Informationen erstellen und die Frage "Welche anderen Dokumente verlinken hier?" Einfach beantworten.
@@ -0,0 +1,29 @@
## Integrations
Outline supports many of the most popular tools on the market without any additional settings or configuration. Just paste links to a YouTube video, Figma file, or Google Spreadsheet to get instant live-embeds in your documents. Take a look at the [integrations directory](https://www.getoutline.com/integrations) for a list of all of the tools that are supported.
Our integration code is also [open-source](https://github.com/outline/outline) and we encourage third party developers and the community to build support for additional tools!
:::info
Most integrations work by simply pasting a link from a supported service into a document.
:::
## Slack
If your team is using Slack to communicate then you’ll definitely want to enable our [Slack Integration](/settings/integrations/slack) to get instant link unfurling for Outline documents and access to the `/outline` slash command to search your knowledge base directly from Slack.
## API
Have some technical skills? Outline is built on a fully featured RPC-style [API](https://www.getoutline.com/developers). Create (or even append to) documents, collections, provision users, and more programmatically. All documents are edited and stored in markdown format – try out this example CURL request to get started:
```bash
curl -XPOST -H "Content-type: application/json" -d '{
"title": "My first document",
"text": "Hello from the API 👋",
"collectionId": "COLLECTION_ID", // find the collection id in the URL bar
"token": "API_TOKEN", // get an API token from https://www.getoutline.com/settings/tokens
"publish": true
}' 'https://www.getoutline.com/api/documents.create'
```
File renamed without changes.
+9
View File
@@ -0,0 +1,9 @@
We hate bugs as much as you and do everything possible to keep the application bug-free and performant. If you see any problems with Outline please get in touch with the team – you can email [hello@getoutline.com](mailto:hello@getoutline.com) directly and we’ll get back to you (hopefully with a fix!) as soon as possible.
## GitHub
If you have a GitHub account then you can also submit bugs directly to the development team on our public [issue tracker](https://github.com/outline/outline/issues).
## Ideas
We’d love to hear your ideas about how Outline can be improved and features you would like to see built. The best place to let the team know is through [GitHub discussions](https://github.com/outline/outline/discussions).
@@ -0,0 +1,17 @@
Outline is a place to build your team knowledge base, you could think of it like your team’s shared library – a place for important documentation, notes, and ideas to live and be discovered. Some things you might want to keep in Outline:
- Documentation
- Sales playbooks
- Support scripts
- Onboarding
- HR documents
- Meeting notes
- …and more
## Structure
Outline allows you to organize documents in "collections", for example these could represent topics like Sales, Product, or HR. Within collections documents can be interlinked and deeply nested to easily build relationships within your knowledge base.
## Search
Outline is built from the ground up to be really fast, and that includes [search](/search). You can start searching from anywhere with the `CMD+K` shortcut – then filter by time, author, and more to find the information you need. Or you can search from within Slack with the `/outline` slash command.
+1
View File
@@ -5,6 +5,7 @@ export default function present(team: Team) {
return {
id: team.id,
name: team.name,
language: team.language,
avatarUrl: team.logoUrl,
slackConnected: !!team.slackId,
googleConnected: !!team.googleId,
+15
View File
@@ -0,0 +1,15 @@
{
"Home": "Startseite",
"Recently updated": "Zuletzt geändert",
"Recently viewed": "Zuletzt gesehen",
"Created by me": "Von mir erstellt",
"Welcome": "Willkommen",
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!": "Diese Sammlung ist eine Kurzanleitung für Outline. Fühlen Sie sich frei, diese Sammlung zu löschen, sobald Ihr Team mit den Grundlagen vertraut ist!",
"Support": "Support",
"Integrations & API": "Integrationen & API",
"Our Editor": "Unser Editor",
"What is Outline": "Was ist Outline",
"Our team’s knowledge base": "Die Wissensbasis unseres Teams",
"Team wiki, documentation, meeting notes, playbooks, onboarding, work logs, brainstorming, & more…": "Team-Wiki, Dokumentation, Besprechungsnotizen, Spielbücher, Onboarding, Arbeitsprotokolle, Brainstorming und mehr…"
}
+12
View File
@@ -0,0 +1,12 @@
{
"Home": "Home",
"Recently updated": "Recently updated",
"Recently viewed": "Recently viewed",
"Created by me": "Created by me",
"Welcome": "Welcome",
"This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!": "This collection is a quick guide to what Outline is all about. Feel free to delete this collection once your team is up to speed with the basics!",
"Support": "Support",
"Integrations & API": "Integrations & API",
"Our Editor": "Our Editor",
"What is Outline": "What is Outline"
}
+28
View File
@@ -0,0 +1,28 @@
// @flow
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import de_DE from "./de_DE.json";
import en_US from "./default.json";
i18n.use(initReactI18next).init({
interpolation: {
escapeValue: false,
},
react: {
useSuspense: false,
},
lng: process.env.DEFAULT_LANGUAGE,
resources: {
en_US: {
translation: en_US,
},
de_DE: {
translation: de_DE,
},
},
});
const t = i18n.getFixedT();
export { t, i18n };
+2376 -1794
View File
File diff suppressed because it is too large. Load diff