Skip to content

Instantly share code, notes, and snippets.

Avatar
🤡
Why So Serious ?

Ayesh Nipun ayeshN

🤡
Why So Serious ?
View GitHub Profile
@ayeshN
ayeshN / App.js
Created Dec 10, 2020
App.js with language switching option
View App.js
import logo from "./logo.svg";
import "./App.css";
import { withTranslation } from "react-i18next";
const App = (props) => {
const { t } = props;
const onLanguageChanged = (event) => {
let language = event.currentTarget.value;
props.i18n.changeLanguage(language);
View App.js
import logo from "./logo.svg";
import "./App.css";
import { withTranslation } from "react-i18next";
const App = (props) => {
const { t } = props;
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
@ayeshN
ayeshN / App.js
Created Dec 10, 2020
Modified App.js
View App.js
import logo from "./logo.svg";
import "./App.css";
import { withTranslation } from "react-i18next";
const App = (props) => {
const { t } = props;
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
@ayeshN
ayeshN / index.js
Created Dec 10, 2020
index.js file
View index.js
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import "./i18n";
import reportWebVitals from "./reportWebVitals";
ReactDOM.render(
<React.StrictMode>
<App />
@ayeshN
ayeshN / i18n.js
Created Dec 10, 2020
i18next configuration file
View i18n.js
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
// //local imports
import en from './locales/en.json';
import sv from './locales/sv.json';
let language = localStorage.getItem('language');
if (language === undefined) {
@ayeshN
ayeshN / sv.json
Created Dec 10, 2020
Swedish locale file
View sv.json
{
"Hi": "Hej",
"Welcome": "Välkommen"
}
@ayeshN
ayeshN / en.json
Created Dec 10, 2020
English locale file
View en.json
{
"Hi": "Hi",
"Welcome": "Welcome"
}
View PasswordHelper.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace B2CUserManagement.Helpers
{
public static class PasswordHelper
{
public static string GenerateNewPassword(int lowercase, int uppercase, int numerics)
View ConfigureServices.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddCors(options =>
{
options.AddPolicy(
"CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
View ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddCors(options =>
{
options.AddPolicy(
"CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()