Skip to content

Docusaurus LTR cleanup#5

Merged
massoudmaboudi merged 9 commits intomasterfrom
docusaurus-ltr
Mar 7, 2021
Merged

Docusaurus LTR cleanup#5
massoudmaboudi merged 9 commits intomasterfrom
docusaurus-ltr

Conversation

@slorber
Copy link
Copy Markdown

@slorber slorber commented Feb 23, 2021

Trying to remove what can be removed :)


You can override the default fa translations provided by docusaurus by editing i18n/fa_IR/code.json.

You can "regenerate" this file by running npm run translate:fa (it may write other files to translate as well but they are not necessary in your case as your homepage has hardcoded Farsi text that you don't need to translate.


Note, you can use custom.css to target css module classes (with a generated classname) without swizzling, by using this trick:

.blog-wrapper [class^="sidebarItem"] {
    padding-right: 0;
}

I think it's better because you won't have to duplicate/maintain the full JS version and can just provide CSS overrrides


Note: Docusaurus currently does not translate some "dynamic/interpolated strings" (will be implemented later):

  • BlogPostItem reading time:

image

  • BlogTagsPostPage:

image

  • DocItem lastUpdated (does not seem used on your site anyway):

image

return <nav className="pagination-nav" aria-label="Blog list page navigation">
<div className="pagination-nav__item pagination-nav__item--next">
{nextPage && <Link className="pagination-nav__link" to={nextPage}>
<div className="pagination-nav__label">&laquo; مطالب قدیمی تر</div>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now translated by docusaurus

</div>
<div className="pagination-nav__item">
{previousPage && <Link className="pagination-nav__link" to={previousPage}>
<div className="pagination-nav__label">مطالب جدید تر &raquo;</div>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now translated by docusaurus

return <nav className="pagination-nav" aria-label="Blog post page navigation">
<div className="pagination-nav__item">
{prevItem && <Link className="pagination-nav__link" to={prevItem.permalink}>
<div className="pagination-nav__sublabel">پست بعدی</div>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now translated by docusaurus

</div>
<div className="pagination-nav__item pagination-nav__item--next">
{nextItem && <Link className="pagination-nav__link" to={nextItem.permalink}>
<div className="pagination-nav__sublabel">پست قبلی</div>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now translated by docusaurus

<BlogSidebar sidebar={sidebar} />
</div>
<main className="col col--8">
<h1>برچسب ها</h1>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now translated by docusaurus

return <nav className="pagination-nav" aria-label="Blog list page navigation">
<div className="pagination-nav__item">
{metadata.previous && <Link className="pagination-nav__link" to={metadata.previous.permalink}>
<div className="pagination-nav__sublabel">قبلی</div>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now translated by docusaurus

@@ -0,0 +1,150 @@
{
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Use this file to override default Docusaurus labels without swizzling the components

import useBaseUrl from '@docusaurus/useBaseUrl';
import Seo from '@theme/Seo';
import styles from './styles.module.css';
const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

FYI I "reswizzled" the component to update it to latest Docusaurus code (which is using prettier for better js code formatting now)

So most of the changes here are related to formatting and updated Docusaurus code

@@ -58,54 +61,81 @@ function BlogPostItem(props) {
</time>
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not yet translated by Docusaurus, so kept your translated label here

@@ -36,18 +34,29 @@ function BlogTagsPostPage(props) {
{count} پست با برچسب &quot;{tagName}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

not yet translated, so kept it in Farsi

import BlogPostItem from '@theme/BlogPostItem';
import Link from '@docusaurus/Link';
import BlogSidebar from '@theme/BlogSidebar';
import Translate from '@docusaurus/Translate';
Copy link
Copy Markdown
Author

@slorber slorber Feb 23, 2021

Choose a reason for hiding this comment

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

Component also reswizzled to update it and format it

<Translate
id="theme.tags.tagsPageLink"
description="The label of the link targeting the tag list page">
View All Tags
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

now correctly translated by docusaurus

<Translate
id="theme.blog.post.readMore"
description="The label used in blog post item excerpts to link to full blog posts">
Read More
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

correctly translated by docusaurus

<Translate
id="theme.tags.tagsListLabel"
description="The label alongside a tag list">
Tags:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

correctly translated by docusaurus

* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Head from '@docusaurus/Head';
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

also reswizzled comp

<div className="col text--right">
<em>
<small>
{/* TODO: wait for using interpolation in translation function */}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

not translated yet (but unused?)

@slorber slorber marked this pull request as ready for review February 23, 2021 16:27
@slorber
Copy link
Copy Markdown
Author

slorber commented Feb 23, 2021

@massoudmaboudi ready for a first review

I think if you could move the DocItem CSS changes to the custom.css file using the technique I mentioned in this PR, we could delete the DocItem comp entirely?

@slorber
Copy link
Copy Markdown
Author

slorber commented Feb 23, 2021

Here's an example of customizing the CSS of the doc title on the doc page:

[class^="docPage"] [class^="docTitle"] {
    color: red;
}

image


.codeBlockContent {
direction: ltr !important;
}
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

can be removed, forced LTR by default for code blocks

@massoudmaboudi massoudmaboudi merged commit 19fb386 into master Mar 7, 2021
@massoudmaboudi massoudmaboudi deleted the docusaurus-ltr branch March 7, 2021 11:26
@slorber
Copy link
Copy Markdown
Author

slorber commented Mar 8, 2021

sweet

is this deployed live?

@slorber
Copy link
Copy Markdown
Author

slorber commented Mar 8, 2021

@massoudmaboudi can you please talk to me on discord asap? Would like to feature your site for the i18n release tomorrow!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants