Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Update ja translations
Browse files Browse the repository at this point in the history
  • Loading branch information
osamajandali committed Mar 19, 2024
1 parent 277e56b commit 97b2b71
Show file tree
Hide file tree
Showing 39 changed files with 178 additions and 123 deletions.
16 changes: 13 additions & 3 deletions src/components/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,28 @@ import Styles from "./styles.module.css";
type Props = {
insight: Insight;
};
const tagsNames: {
[key: string]: string;
} = {
Culture: "culture",
Knowledge: "knowledge",
Tools: "tools",
"文化": "culture",
"知識": "knowledge",
"ツール": "tools"
}
const Card = ({ insight: { url, title, tags } }: Props) => {
return (
<a className={Styles.wrapper} href={url}>
<div className={`${Styles.container} hover:border-primary`}>
<div className={Styles.tags}>
{tags?.map((tag) => (
{tags?.map((tag: string) => (
<span
key={tag}
className={Styles.tag}
style={{
backgroundColor: `var(--tag-${tag.toLowerCase()})`,
color: `var(--tag-${tag.toLowerCase()}-text)`,
backgroundColor: `var(--tag-${tagsNames[tag]})`,
color: `var(--tag-${tagsNames[tag]}-text)`,
}}
>
{tag}
Expand Down
16 changes: 14 additions & 2 deletions src/components/Form.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
import "@fontsource/nunito-sans/400.css";
import { Icon } from "astro-icon";
const { title, containerClass } = Astro.props;
import { getLangFromUrl } from '../i18n/utils';
const lang = getLangFromUrl(Astro.url);
const texts={
en: {
title: "Sign up to our newsletter",
button: "Sign up"
},
ja: {
title: "ニュースレターにサインアップしてください",
button: "サインアップ"
}
}
---

<section id="get-report" class={containerClass}>
Expand All @@ -21,7 +33,7 @@ const { title, containerClass } = Astro.props;
<div>
<Icon name="newsletter" width="196" style={{ margin: "auto" }} />
</div>
<h1>{title}</h1>
<h1>{texts[lang].title}</h1>

<div class="mc-field-group">
<input
Expand Down Expand Up @@ -62,7 +74,7 @@ const { title, containerClass } = Astro.props;
<div class="clear">
<input
type="submit"
value="Sign up"
value={texts[lang].button}
name="subscribe"
id="mc-embedded-subscribe"
class="button"
Expand Down
74 changes: 49 additions & 25 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,60 @@ const lang = getLangFromUrl(Astro.url);
import { Icon } from "astro-icon";
import LanguagePicker from './LanguagePicker.astro';
const { isHomepage } = Astro.props;
const links = [
{
label: "What is green software",
url: "https://learn.greensoftware.foundation/introduction#what-is-green-software",
},
{
label: "Executive Summary",
url: `/${lang}/executive-summary`,
},
{
label: "Methodology",
url: `/${lang}/methodology`,
},
{
label: "Theory of Change",
url: "https://greensoftware.foundation/articles/theory-of-change",
},
{
label: "Survey Data",
url: `/${lang}/survey`,
},
];
const links = {
en:[
{
label: "What is green software",
url: "https://learn.greensoftware.foundation/introduction#what-is-green-software",
},
{
label: "Executive Summary",
url: `/en/executive-summary`,
},
{
label: "Methodology",
url: `/en/methodology`,
},
{
label: "Theory of Change",
url: "https://greensoftware.foundation/articles/theory-of-change",
},
{
label: "Survey Data",
url: `/en/survey`,
},
],
ja:[
{
label: "グリーンソフトウェアとは",
url: "https://learn.greensoftware.foundation/introduction#what-is-green-software",
},
{
label: "概要",
url: `/ja/executive-summary`,
},
{
label: "方法論",
url: `/ja/methodology`,
},
{
label: "変化の理論",
url: "https://greensoftware.foundation/articles/theory-of-change",
},
{
label: "調査データ",
url: `/ja/survey`,
},
]
};
---
<div class=" max-w-5xl mx-auto px-4 my-4">
<LanguagePicker />
<nav
class="text-xs lg:text-sm text-center font-bold flex items-center justify-between flex-wrap relative"
>
<a href="/" aria-label="SoGS Logo">
<a href={`/${lang}`} aria-label="SoGS Logo">
<Icon name="logo-alt" className="w-32 lg:w-40" />
</a>
<button
Expand All @@ -47,7 +71,7 @@ const links = [
class="hidden lg:flex gap-4 items-center absolute lg:static bg-white lg:bg-transparent shadow-md lg:shadow-none z-50 top-10 left-0 w-full lg:w-auto py-3 lg:py-0"
>
{
links.map(({ label, url }) => (
links[lang].map(({ label, url }) => (
<li class="py-3 lg:py-0">
<a
href={url}
Expand All @@ -69,7 +93,7 @@ const links = [
"
href=`/${lang}`
>
More Insights
{lang ==="ja"? "さらに詳しく": "More Insights"}
</a>
</li>
)
Expand Down
10 changes: 7 additions & 3 deletions src/components/InsightsCatalog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch, SearchBox, PoweredBy, Hits, RefinementList } from 'react-instantsearch-hooks-web';
import { InstantSearch, SearchBox, PoweredBy, Hits, RefinementList, Configure } from 'react-instantsearch-hooks-web';
import Card from "../Card";
import Styles from "./styles.module.css";

Expand All @@ -10,12 +10,16 @@ const Hit = ({ hit }: {
hit: Insight
}) =>
<Card insight={{ url: `insights/${hit.url}`, title: hit.title, tags: hit.tags, insightNo: hit.insightNo }} />
const InsightsCatalog = () => {
const InsightsCatalog = ({ language }: {language: string}) => {
return (
<section className={Styles.container}>
<InstantSearch searchClient={searchClient} indexName="Insights - SoGS">
<Configure filters={`language:${language}`} />
<SearchBox
placeholder="Search insights..."

placeholder={
language === 'ja' ? "インサイトを検索..." :
"Search insights..."}
classNames={
{
form: 'relative',
Expand Down
14 changes: 3 additions & 11 deletions src/icons/twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/layouts/InsightLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const { title, image, shortDescription, twitter } = frontmatter;
import "../styles/base.css";
import Layout from "./Layout.astro";
const { pathname } = Astro.url;
import { getLangFromUrl } from '../i18n/utils';
const lang = getLangFromUrl(Astro.url);
const twitterURLEncoded = encodeURIComponent(
twitter.replace(
"https://stateof.greensoftware.foundation",
Expand Down Expand Up @@ -39,15 +40,17 @@ const linkedinURLEncoded = encodeURIComponent(
<div
class="social max-w-5xl mx-auto flex items-center justify-end gap-4 mb-4"
>
<span> Share</span>
<span>{
lang ==='ja'? "シェア": "Share"
} </span>
<a
id="twitter-share"
class="button icon"
href={`https://twitter.com/intent/tweet?text=${twitterURLEncoded}`}
target="_blank"
rel="noopener noreferrer"
>
<Icon name="twitter" height="24" color="#006d68" />
<Icon name="twitter" height="16" color="#006d68" />
</a>
<a
id="linkedin-share"
Expand Down
68 changes: 40 additions & 28 deletions src/lib/algolia.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,56 @@
import * as dotenv from "dotenv"
dotenv.config()
import * as dotenv from "dotenv";
dotenv.config();

import algoliasearch from "algoliasearch"
import algoliasearch from "algoliasearch";
const client = algoliasearch(
process.env.ALGOLIA_APP_ID,
process.env.ALGOLIA_WRITE_API_KEY
)
);

// 1. Build a dataset
import fs from "fs"
import path from "path"
import matter from "gray-matter"
import removeMd from "remove-markdown"
import fs from "fs";
import path from "path";
import matter from "gray-matter";
import removeMd from "remove-markdown";

const filenames = fs.readdirSync(path.join("./src/pages/insights"))
const data = filenames.map(filename => {
try {
const markdownWithMeta = fs.readFileSync("./src/pages/insights/" + filename)
const { data: frontmatter, content } = matter(markdownWithMeta)
return {
url: filename.replace(/\.mdx$/, ''),
objectID: filename.replace(/\.mdx$/, ''),
title: frontmatter.title,
tags: frontmatter.tags,
insightNo: frontmatter.insightNo,
content: removeMd(content).replace(/\n/g, ""),
// Function to process files in a given insights directory
function processInsightsDirectory(directory) {
const filenames = fs.readdirSync(path.join(directory));
const data = filenames.map((filename) => {
try {
const fullPath = path.join(directory, filename);
const markdownWithMeta = fs.readFileSync(fullPath);
const { data: frontmatter, content } = matter(markdownWithMeta);
const language = directory.split('/')[3];
return {
url: filename.replace(/\.mdx?$/, ''),
objectID: language + " - " + filename.replace(/\.mdx?$/, ''),
title: frontmatter.title,
tags: frontmatter.tags,
insightNo: frontmatter.insightNo,
content: removeMd(content).replace(/\n/g, ""),
language
};
} catch (e) {
console.log(e.message);
}
} catch (e) {
console.log(e.message)
}
})
});
return data;
}

// 1. Build datasets for each language
const englishInsights = processInsightsDirectory("./src/pages/en/insights/");
const japaneseInsights = processInsightsDirectory("./src/pages/ja/insights/");

// 2. Send the dataset in JSON format
// Combine the insights from both languages
const combinedData = [...englishInsights, ...japaneseInsights];

// 2. Send the combined dataset in JSON format
const index = client.initIndex('Insights - SoGS');

index.saveObjects(data)
index.saveObjects(combinedData)
.then(({ objectIDs }) => {
console.log("Algolia: All records have been imported");
})
.catch(err => {
console.error(err);
});
});
4 changes: 2 additions & 2 deletions src/pages/en/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Layout from "../../layouts/Layout.astro";
import InsightsCatalog from "../../components/InsightsCatalog";
---

<Layout isHomepage>
<Layout isHomepage >
<header
class="bg-gradient-to-tr from-gray-darkest to-gray-dark max-w-5xl mx-auto rounded-2xl py-12 px-4 relative mb-4"
>
Expand Down Expand Up @@ -47,7 +47,7 @@ import InsightsCatalog from "../../components/InsightsCatalog";
</div>
</header>
<div class="max-w-5xl mx-auto">
<InsightsCatalog client:load />
<InsightsCatalog language="en" client:load />
<Form title="Sign up to our newsletter" />
</div>
</Layout>
10 changes: 4 additions & 6 deletions src/pages/ja/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ import InsightsCatalog from "../../components/InsightsCatalog";
<h1
class="text-center text-xl lg:text-3xl font-extrabold mb-2 text-white"
>
2023 State of Green Software
2023年 グリーンソフトウェアの現状
</h1>
<p class="text-center text-gray-300 text-sm lg:text-base">
A new report that brings global insights and data from industry leaders
and researchers to the forefront to reduce software's harm to Earth and
increase investment in decarbonizing software at scale.
業界リーダーや研究者からのグローバルな洞察とデータを提供する新しいレポートで、地球へのソフトウェアの害を減らし、大規模なソフトウェアの脱炭素化への投資を増やすことを目指します.
</p>
<div>
<a
Expand All @@ -40,14 +38,14 @@ import InsightsCatalog from "../../components/InsightsCatalog";
rel="noopener noreferrer"
target="_blank"
>
<span>By</span>
<span>提供</span>
<Icon name="logo-gsf" width="100" />
</a>
</div>
</div>
</header>
<div class="max-w-5xl mx-auto">
<InsightsCatalog client:load />
<InsightsCatalog language="ja" client:load />
<Form title="Sign up to our newsletter" />
</div>
</Layout>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Learn more about this insight here ➡️ https://stateof.greensoftware.foundati
#Sustainability #TechNews"
tags:
- Culture
- 文化
---

IBMが3,000人のCEOを対象に実施した[世界規模の調査](https://www.ibm.com/thought-leadership/institute-business-value/en-us/c-suite-study/ceo)によると、**83%**のCEOが、サステナビリティに対する投資は、今後5年以内にビジネス成果の向上につながる要因になると捉えています。しかし、同じ調査によると、サステナビリティをビジネスの最優先事項として捉えているCEOは**37%**に過ぎず、63%は捉えていないことが分かります。ガートナー社の[調査](https://www.gartner.com/en/newsroom/press-releases/2022-05-18-gartner-survey-reveals-significant-shifts-in-ceo-thinking-on-sustainability-workforce-issues-and-inflation-in-2022)によると、環境の持続可能性が、ブランドの信頼性と並んで初めて競争上の差別化要因として位置付けられ、78%のCEOが、サステナビリティは投資の動機付けになると考えていることが分かりました。つまり、今後サステナビリティが市場競争力や投資の重要な要素になるという兆しの高まりにもかかわらず、大多数のCEOが、サステナビリティ対策の重要性を認識できていないのです。
Expand Down
Loading

0 comments on commit 97b2b71

Please sign in to comment.