Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Feature/#190 i18n #293

Closed
wants to merge 6 commits into from
Closed
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
99 changes: 52 additions & 47 deletions src/WebApi/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,55 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft": "Information",
"System": "Information"
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft": "Information",
"System": "Information"
},
"Console": {
"FormatterName": "simple",
"FormatterOptions": {
"SingleLine": true
}
}
},
"Console": {
"FormatterName": "simple",
"FormatterOptions": {
"SingleLine": true
}
}
},
"IdentityServer": {
"Authority": "https://localhost:8000",
"Clients": [
{
"ClientId": "crpg-web-ui",
"ClientName": "cRPG Web UI",
"ClientSecrets": [{ "Value": "" }],
"RequireClientSecret": false,
"AllowedGrantTypes": ["authorization_code"],
"AllowedScopes": ["openid", "user_api"],
"AllowedCorsOrigins": ["http://localhost:8080"],
"RedirectUris": ["http://localhost:8080", "http://localhost:8080/silent-renew.html"],
"PostLogoutRedirectUris": ["http://localhost:8080"],
"AccessTokenType": "Jwt",
"RequireConsent": false,
"AccessTokenLifetime": 3600,
"IdentityTokenLifetime": 300,
"RequirePkce": true,
"AllowAccessTokensViaBrowser": true,
"AllowOfflineAccess": true
},
{
"ClientId": "crpg-game-server",
"ClientName": "cRPG Game Server",
"ClientSecrets": [{ "Value": "rA1Rpt3Nf9mwBQNsWP2Zzl+DrFkhnHVki8uwN1pycCU=" }],
"AllowedGrantTypes": ["client_credentials"],
"AllowedScopes": ["openid", "game_api"],
"AccessTokenLifetime": 31536000
}
],
"Providers": {
"Steam": { "ApplicationKey": "CD25FE3041550BD0F4B36A53F35E033F" }
}
},
"Urls": "https://localhost:8000"
"IdentityServer": {
"Authority": "https://localhost:8000",
"Clients": [
{
"ClientId": "crpg-web-ui",
"ClientName": "cRPG Web UI",
"ClientSecrets": [{ "Value": "" }],
"RequireClientSecret": false,
"AllowedGrantTypes": ["authorization_code"],
"AllowedScopes": ["openid", "user_api"],
"AllowedCorsOrigins": ["http://localhost:8080"],
"RedirectUris": [
"http://localhost:8080",
"http://localhost:8080/silent-renew.html"
],
"PostLogoutRedirectUris": ["http://localhost:8080"],
"AccessTokenType": "Jwt",
"RequireConsent": false,
"AccessTokenLifetime": 3600,
"IdentityTokenLifetime": 300,
"RequirePkce": true,
"AllowAccessTokensViaBrowser": true,
"AllowOfflineAccess": true
},
{
"ClientId": "crpg-game-server",
"ClientName": "cRPG Game Server",
"ClientSecrets": [
{ "Value": "rA1Rpt3Nf9mwBQNsWP2Zzl+DrFkhnHVki8uwN1pycCU=" }
],
"AllowedGrantTypes": ["client_credentials"],
"AllowedScopes": ["openid", "game_api"],
"AccessTokenLifetime": 31536000
}
],
"Providers": {
"Steam": { "ApplicationKey": "FE0A32B959ED3C6561E1F3F3BE68F75D" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discarding pls, just add to git stash

}
},
"Urls": "https://localhost:8000"
}
3 changes: 2 additions & 1 deletion src/WebUI/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"tabWidth": 2,
"htmlWhitespaceSensitivity": "ignore",
"arrowParens": "avoid",
"trailingComma": "es5"
"trailingComma": "es5",
"endOfLine": "auto"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if you need to change the default value (lf)

}
11 changes: 11 additions & 0 deletions src/WebUI/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/WebUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"query-string": "^6.13.8",
"vue": "^2.6.11",
"vue-class-component": "^7.2.3",
"vue-i18n": "^8.27.2",
"vue-property-decorator": "^9.1.2",
"vue-router": "^3.2.0",
"vue2-leaflet": "^2.6.0",
Expand Down
86 changes: 72 additions & 14 deletions src/WebUI/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
<template>
<div class="is-flex-grow-1 is-flex is-flex-direction-column">
<nav v-if="user" class="is-flex-grow-0">
<nav>
<b-navbar fixed-top :close-on-click="false">
<template slot="brand">
<b-navbar-item tag="router-link" :to="{ path: '/' }">cRPG</b-navbar-item>
<template slot="brand" v-if="user">
<b-navbar-item tag="router-link" :to="{ path: '/' }">
{{ $t('appHome') }}
</b-navbar-item>
</template>

<template slot="start">
<b-navbar-item tag="router-link" :to="{ path: '/characters' }">Characters</b-navbar-item>
<b-navbar-item tag="router-link" :to="{ path: '/shop' }">Shop</b-navbar-item>
<b-navbar-item tag="router-link" :to="{ path: '/clans' }">Clans</b-navbar-item>
<template slot="start" v-if="user">
<b-navbar-item tag="router-link" :to="{ path: '/characters' }">
{{ $t('appCharacters') }}
</b-navbar-item>
<b-navbar-item tag="router-link" :to="{ path: '/shop' }">
{{ $t('appShop') }}
</b-navbar-item>
<b-navbar-item tag="router-link" :to="{ path: '/clans' }">
{{ $t('appClans') }}
</b-navbar-item>
<!-- <b-navbar-item tag="router-link" :to="{ path: '/strategus' }">Strategus</b-navbar-item> -->
</template>

<template slot="end">
<div class="navbar-end">
<b-dropdown
v-model="language"
@change="onLanguageChanged"
position="is-bottom-left"
aria-role="menu"
>
<template #trigger>
<a class="navbar-item" role="button">
<span>{{ $t('languageDropDownText') }}</span>
<b-icon icon="caret-down"></b-icon>
</a>
</template>

<b-dropdown-item v-for="language in languages" :value="language" :key="language">
{{ $t(language) }}
</b-dropdown-item>
</b-dropdown>
</div>

<b-navbar-item tag="div" v-if="user">
<div class="media">
<div class="media-content">
Expand All @@ -33,20 +61,20 @@
<b-dropdown-item has-link aria-role="menuitem" v-if="isModeratorOrAdmin">
<router-link to="/admin">
<b-icon icon="user-shield" />
Administration
{{ $t('appAdministration') }}
</router-link>
</b-dropdown-item>

<b-dropdown-item has-link aria-role="menuitem">
<router-link to="/settings">
<b-icon icon="cog" />
Settings
{{ $t('appSettings') }}
</router-link>
</b-dropdown-item>

<b-dropdown-item value="home" aria-role="menuitem" @click="signOut">
<b-icon icon="sign-out-alt" />
Sign out
{{ $t('appSignOut') }}
</b-dropdown-item>
</b-dropdown>
</figure>
Expand All @@ -66,19 +94,19 @@
>
<div class="level">
<div class="level-item">
<a href="https://www.patreon.com/crpg" target="_blank" title="Donate on Patreon">
<a href="https://www.patreon.com/crpg" target="_blank" :title="this.$t('appDonate')">
<b-icon icon="patreon" pack="fab" size="is-large" aria-label="cRPG Patreon" />
</a>
</div>

<div class="level-item">
<a href="https://discord.gg/c-rpg" target="_blank" title="Join our Discord">
<a href="https://discord.gg/c-rpg" target="_blank" :title="this.$t('appJoinDiscord')">
<b-icon icon="discord" pack="fab" size="is-large" aria-label="cRPG Discord" />
</a>
</div>

<div class="level-item">
<a href="https://forum.c-rpg.eu" target="_blank" title="Join our Forum">
<a href="https://forum.c-rpg.eu" target="_blank" :title="this.$t('appJoinForum')">
<b-icon icon="discourse" pack="fab" size="is-large" aria-label="cRPG Forum" />
</a>
</div>
Expand All @@ -87,7 +115,7 @@
<a
href="https://store.steampowered.com/app/261550/Mount__Blade_II_Bannerlord"
target="_blank"
title="Buy the game"
:title="this.$t('appBuyGame')"
>
<b-icon icon="steam" pack="fab" size="is-large" aria-label="Mount & Blade Steam page" />
</a>
Expand All @@ -101,10 +129,15 @@
import { Component, Vue } from 'vue-property-decorator';
import userModule from '@/store/user-module';
import User from '@/models/user';
import Language from '@/models/language';
import { signInCallback, signOut, signInSilent } from './services/auth-service';
import { i18n } from './main';

@Component
export default class App extends Vue {
language = Language.English;
languageStoreKey = 'language';

get user(): User | null {
return userModule.user;
}
Expand All @@ -113,6 +146,15 @@ export default class App extends Vue {
return userModule.isModeratorOrAdmin;
}

get languages(): Language[] {
const languages = Object.values(Language);
const index = languages.indexOf(this.language, 0);
if (index > -1) {
languages.splice(index, 1);
}
return languages;
}

async beforeCreate() {
userModule.setUserLoading(true);
try {
Expand Down Expand Up @@ -145,8 +187,24 @@ export default class App extends Vue {
}
}

mounted() {
const storedLanguage = localStorage.getItem(this.languageStoreKey);
if (storedLanguage) {
const language = Object.values(Language).find(l => l === storedLanguage);
if (language) {
this.language = language;
i18n.locale = language;
}
}
}

signOut(): void {
signOut();
}

onLanguageChanged(language: string): void {
i18n.locale = language;
localStorage.setItem(this.languageStoreKey, language);
}
}
</script>
Loading