techworkersco / twc-site-berlin

Berlin Chapter Page
https://TechWorkersBerlin.com
10 stars 15 forks source link

Liquid plugin bug #260

Closed shushugah closed 10 months ago

shushugah commented 10 months ago

The Polish version of website renders "error" for date-times. I suspect this has to do with the Locale keys not being fully available.

Debugging

# i18n_filter.rb
    def localize(input, locale, format=nil)
      # binding.pry if locale == 'pl'
      if input.is_a? String
        date_format = Date.parse(input)
      else
        date_format = input
      end
      load_translations(locale)
      format = (format =~ /^:(\w+)/) ? $1.to_sym : format
      I18n.l date_format, :format => format
    rescue
      binding.pry
      "error"
    end

Polish keys seem to be missing here when calling I18n.backend.send(:translations) It results in

{:pl=>
  {:date=>
    {:month_names=>#<Proc:0x0000000107e5e6d0 /Users/yonatan.miller/dev/twc-site-berlin/_plugins/../_i18n/custom_polish.rb:4 (lambda)>,
     :abbr_month_names=>#<Proc:0x0000000107e5e6a8 /Users/yonatan.miller/dev/twc-site-berlin/_plugins/../_i18n/custom_polish.rb:15 (lambda)>,
     :abbr_day_names=>#<Proc:0x0000000107e5e680 /Users/yonatan.miller/dev/twc-site-berlin/_plugins/../_i18n/custom_polish.rb:24 (lambda)>}},
 :langs=>{:de=>"Deutsch", :en=>"English", :pl=>"Polski", :ru=>"Русский"},
 :home=>
  {:summary=>
    "Berlin Tech Workers Coalition is a landing page for tech workers looking to organise their workplace. Whether it is through <a href=\"/works-councils\">Works Councils</a> (Betriebsräte), union campaigns for higher wages, or broader struggles against racism and gentrification, we are here to support you! Tech Won’t Save Us...Organise! ✊ We are the largest English speaking network of Works Councils, tech workers and trade union members supporting each other in different tech companies like Soundcloud, Contentful, ShareNow, Amazon, SumUp, N26, TikTok and maybe your company!",
   :black_lives_matter=>
    {:title=>"Black Lives Matter",
     :summary=>
      "We encourage all Tech Workers to stand in solidarity with the Black Lives Matter movement in the fight for racial justice. For ways to support and more information on local Black initiatives in Berlin and Germany, we refer to&#58; <a href=\"https://www.blacklivesmatterberlin.de\" >Black Lives Matter Berlin</a>, <a href=\"http://isdonline.de\" >Initiative Schwarze Menschen in Deutschland (ISD)</a>, <a href=\"https://www.eoto-archiv.de\" >Each One Teach One</a>"},
   :zero_covid=>
    {:title=>"ZERO COVID",
     :summary=>
      "We as TWC Berlin support the <a href=\"https://zero-covid.org/language/en/\">ZeroCovid</a> campaign. Employers must take responsibility for the health and safety of workers and support working from home wherever possible. In all branches of industry where this is not possible and that are non-essential, a solidarity shutdown is urgently needed to fight the pandemic. If your employer fails to protect your health by adequate measures, or denies home office and you would like to discuss how we can support you, please contact us (also anonymously) on zero-covid@TechWorkersBerlin.com"},
   :dw_enteignen=>
    {:summary=>
nen</a> campaign. If you live in Berlin and are eligible to vote, find out how to sign <a href=\"https://www.dwenteignen.de/unterschreiben/\">here</a>."},
[45] pry(#<#<Class:0x0000000107ef4f68>>)> I18n.backend.send(:translations)
=> {:pl=>
  {:date=>
    {:month_names=>#<Proc:0x0000000107e5e6d0 /Users/yonatan.miller/dev/twc-site-berlin/_plugins/../_i18n/custom_polish.rb:4 (lambda)>,
     :abbr_month_names=>#<Proc:0x0000000107e5e6a8 /Users/yonatan.miller/dev/twc-site-berlin/_plugins/../_i18n/custom_polish.rb:15 (lambda)>,
     :abbr_day_names=>#<Proc:0x0000000107e5e680 /Users/yonatan.miller/dev/twc-site-berlin/_plugins/../_i18n/custom_polish.rb:24 (lambda)>}},
 :langs=>{:de=>"Deutsch", :en=>"English", :pl=>"Polski", :ru=>"Русский"},
 :home=>
  {:summary=>
    "Berlin Tech Workers Coalition is a landing page for tech workers looking to organise their workplace. Whether it is through <a href=\"/works-councils\">Works Councils</a> (Betriebsräte), union campaigns for higher wages, or broader struggles against racism and gentrification, we are here to support you! Tech Won’t Save Us...Organise! ✊ We are the largest English speaking network of Works Councils, tech workers and trade union members supporting each other in different tech companies like Soundcloud, Contentful, ShareNow, Amazon, SumUp, N26, TikTok and maybe your company!",
   :black_lives_matter=>
    {:title=>"Black Lives Matter",
     :summary=>
      "We encourage all Tech Workers to stand in solidarity with the Black Lives Matter movement in the fight for racial justice. For ways to support and more information on local Black initiatives in Berlin and Germany, we refer to&#58; <a href=\"https://www.blacklivesmatterberlin.de\" >Black Lives Matter Berlin</a>, <a href=\"http://isdonline.de\" >Initiative Schwarze Menschen in Deutschland (ISD)</a>, <a href=\"https://www.eoto-archiv.de\" >Each One Teach One</a>"},
   :zero_covid=>
    {:title=>"ZERO COVID",
     :summary=>
      "We as TWC Berlin support the <a href=\"https://zero-covid.org/language/en/\">ZeroCovid</a> campaign. Employers must take responsibility for the health and safety of workers and support working from home wherever possible. In all branches of industry where this is not possible and that are non-essential, a solidarity shutdown is urgently needed to fight the pandemic. If your employer fails to protect your health by adequate measures, or denies home office and you would like to discuss how we can support you, please contact us (also anonymously) on zero-covid@TechWorkersBerlin.com"},
   :dw_enteignen=>
    {:summary=>
nen</a> campaign. If you live in Berlin and are eligible to vote, find out how to sign <a href=\"https://www.dwenteignen.de/unterschreiben/\">here</a>."},
   :events=>{:title=>"5 Recent events", :summary=>"Find [all upcoming events here](/events)"},
   :news=>{:title=>"Recent articles"}},
 :connect=>
  {:info=>"Get involved! @TechWorkersBER",
   :description=>"The easiest way to get involved is to attend one of our upcoming <a href=\"/events\" >events</a>.",
   :title=>"Kontakt",
   :email=>"Email",
   :name=>"Name",
   :public_link=>"Public link",
   :company=>"Your employer",
   :how_did_hear=>"How can we support your personal goals?",
   :subscribe_to_slack=>"Subscribe to Slack",
   :subscribe_to_newsletter=>"Subscribe to Newsletter",
   :subscribe=>"Join",
t</a>",
   :number=>"Phone number"},
 :global=>
  {:edit_this_page=>"Edit This Page",
   :code_of_conduct=>
    {:title=>"Code of Conduct",
     :summary=>
en unless express consent is given."},
   :accessibility=>
    {:title=>"Accessibility",
     :summary=>
kersBerlin.com</a>."}},
shushugah commented 10 months ago

My two hunches are either...one of the YAML files is misindented, causing issues for the other ones....or load-order of the custom plugin should be explicitly done after the I18n is loaded, perhaps this is useful https://jekyllrb.com/docs/plugins/hooks/

shushugah commented 10 months ago

Removing the English file, and making either Polish language, or even German or Russian language doesn't cause any issues. I tried bissecting the YAML file, to see if there's any offending YAML language code, but when the English language is loaded, it expects time.formats.default present, but then screws with Polish locale.

shushugah commented 10 months ago

Fixed, removed some lines of YAML in English file