Giter VIP home page Giter VIP logo

Comments (7)

styxlab avatar styxlab commented on June 11, 2024

@LukasJokubas: Thanks a lot for your support 😄

It's a good idea to separate hard-coded text into a file, and shadowing is really not intended for this use case. Could you please help me by listing all the locations with hard coded texts?

Yeah, an image zoom plugin would be awesome. Just let me know what you need from my side, to get you started.

from gatsby-theme-try-ghost.

LukasJokubas avatar LukasJokubas commented on June 11, 2024

Files where I found static strings:

  • /gatsby-theme-try-ghost/src/components/common/AuthorList.js
  • /gatsby-theme-try-ghost/src/components/common/HeaderAuthor.js
  • /gatsby-theme-try-ghost/src/components/common/HeaderTag.js
  • /gatsby-theme-try-ghost/src/components/common/Layout.js
  • /gatsby-theme-try-ghost/src/components/common/Pagination.js
  • /gatsby-theme-try-ghost/src/components/common/PreviewPosts.js
  • /gatsby-theme-try-ghost/src/pages/404.js
  • gatsby-theme-ghost-dark-mode/src/components/common/DarkModeToggle.js (button title attribute value)
  • gatsby-theme-ghost-toc/src/components/common/TableOfContents.js
  • gatsby-theme-ghost-members/src/components/common/Subscribe.js
  • gatsby-theme-ghost-members/src/components/common/SubscribeButton.js
  • gatsby-theme-ghost-members/src/components/common/SubscribeForm.js
  • gatsby-theme-ghost-members/src/components/common/SubscribeOverlay.js
  • @tryghost/helpers/lib/reading-time.js

from gatsby-theme-try-ghost.

styxlab avatar styxlab commented on June 11, 2024

@LukasJokubas: I just finished the implementation and updated all packages. As you can see from the merge, there is a lang.js file in the src/utils directory, with the following structure:

const lang = {
  en: {
    A_COLLECTION_OF: `A collection of`,
    BY_THIS_AUTHOR: `by this author`,
    ...
  },
}

Please do not shadow this file, rather add your language to it. The language used during compile can be selected in siteConfig.js with a new locale flag.

I also wrote a small helper function for selecting the texts (see src/utils/use-lang.js). This function ensures that you get a build time error, if you select a text that is not present in the language file. So, you can always be assured that a successful build contains all texts!

You may want to override the locale setting programmeticaly. This is also possible by calling the useLang function with an argument, such as useLang('en').

Also note the use in plugins: Every plugin should get it's own copy of src/utils/use-lang.js and a plugin specific lang.js file, that way the core project stays independent of plugin authors.

Finally: Please contribute your language files to this project. Just open a PR or send it directly to me for inclusion.

P.S.: Looking forward to the image zoom plugin!

from gatsby-theme-try-ghost.

styxlab avatar styxlab commented on June 11, 2024

UPDATE: I removed the locale flag in siteConfig.js as we already have the lang property from the Ghost settings. Therefore, language is now taken from the settings in the Ghost Admin panel under General Settings -> Publication Language.

from gatsby-theme-try-ghost.

LukasJokubas avatar LukasJokubas commented on June 11, 2024

@styxlab thanks for getting to this so quickly.

I do have a few observations though:

SubscribeForm.js and SubscribeOverlay.js

  • Value of the HiddenLabel should probably be translatable as well
  • It would be nice to have variables like {site.title} directly in lang.js so it could be put at the begining of the sentence
  • [email protected] placeholder should be translatable

HeaderTag.js
Some languages require 3 strings displayed for different ranges of post counts.

Example: A total of {n} posts:
Viso {n} įrašas n -> 1, 21, 31, 41...
Viso {n} įrašai n -> 2,3,4,5,6,7,8,9,22,23,24,25,26,27,28,29,32,33,34,...
Viso {n} įrašų n -> 0,10,11,12,13,14,15,16,17,18,19,20,30,40,50...

PreviewPosts.js
Example: See all {n} posts
Žiūrėti visus {n} įrašą n -> 21, 31, 41...
Žiūrėti visus {n} įrašus n -> 2,3,4,5,6,7,8,9,22,23,24,25,26,27,28,29,32,33,34,...
Žiūrėti visus {n} įrašų n -> 10,11,12,13,14,15,16,17,18,19,20,30,40,50...

HeaderAuthor.js
String "Website" should be translatable

AuthorList.js
String "by" should be translatable

Layout.js
"Latest posts" a tag could be replaced by Gatsby Link to / as it is internal link.
Would be nice to be able to control footer links in siteConfig.js
Footer social links could use target attribute _blank and rel attributes noopener and noreferrer

PostCard.js
Excerpt should be truncated, because when excerpt is missing in Ghost, first paragraph is pulled in, or even worse, if the first content card in ghost is HTML containing a long text, all of it gets pulled in.
Would be nice to be able to disable displaying of post authors in siteConfig.js

Thanks a lot for your help, I will send over my lang files when finished.

from gatsby-theme-try-ghost.

styxlab avatar styxlab commented on June 11, 2024

I've implemented most of your suggestions, except:

  • 3 strings in HeaderTag.js and PreviewPosts.js (this would require injecting calc functions)
  • excerpt should be truncated (it is already truncated, but only if given)
  • control footer links in siteConfig.js (*)
  • disable displaying of post authors in siteConfig.js (*)

Note that the text() function now contains a second parameter, which is a default text. I made use of it for the site title: If not defined in lang.js the standard site.title is displayed, but you can override the title by adding a SITE_TITLE entry in lang.js. I also added a second language to the lang.js files.

These are all great suggestions, so if you want to implement the ones that I missed out, you are more than welcome to issue a PR!

(*) I don't want to allow modifying the Casper style. So these features should be implemented via another theme and not be included as configuration options for Casper.

from gatsby-theme-try-ghost.

styxlab avatar styxlab commented on June 11, 2024

Closing as delivered. Can always reopen, if needed.

from gatsby-theme-try-ghost.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.