Jan Kaczorowski
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Universal translations ## Założenia - tłumaczenia umożliwiają zarówno tłumaczenie obiektów Ruby, jak i treści zupełnie nie związanych z obiektami Ruby (wtedy localizable: NULL) - nie ma podziału: oryginalna treść vs. tłumaczenia. Wszystkie treści dla użytkownika są tłumaczeniem (jakimś) a języki są względem siebie równoważne - umożliwiamy nadpisywanie tłumaczeń przez GraphQL (o ile user ma uprawnienia ofkorz) - każdemu użytkownikowi graph wysyla treść w jego języku z bazy (user.locale) - jeżeli user nie jest zalogowany to polegamy na x-language lub accept-language - propozycje? a może powinniśmy dodać domyślny język na poziomie festiwalu i na niego fallbackować? jednak wtedy wciąż trzeba jakoś obsłużyć zmianę języka z "wybieraka" na stronie ## Model ```plantuml @startuml note top of Translation : z obsługą PaperTraila dla najprostszego wersjonowania class Translation { + id -> FK + localizable_type:string NULLABLE + localizable_id:bigint NULLABLE + key:string NOT NULL + value:string NOT NULL + lang:string NOT NULL /ISO 639-1 code/ } package Localizables <<Node>> { .Translation <|-- Restaurant .Translation <|-- MenuPosition .Translation <|-- FestivalEditionRestaurant .Translation <|-- Menu } note top of Localizables : i inne modele @enduml ``` | localizable_type | localizable_id | key | value | lang | |------------------|----------------|-----------------------------|------------------------------------------------------|------| | Tag | 1 | name | romantyczna | pl | | Tag | 1 | name | romantic | en | | Festival | 1 | slogan | Najlepsze autorskie restauracje w festiwalowej cenie | pl | | <NULL> | <NULL> | festivals.rw.faq.question_1 | Czy tu się w ogóle można najeść? | pl | | <NULL> | <NULL> | festivals.rw.faq.answer_1 | I to jeszcze jak! | pl | ## Jaki język użytkownika? zasadniczo polegamy na jezyku z `user.locale` - więc nie bierzemy tego dynamicznie na każdym requeście z headera `x-language`...chyba że user nie jest zalogowany Powód jest taki, że chcemy żeby na obcojęzycznej przeglądarce user wciąż widział treści w ustawionym przez siebie języku, nie w automatycznym języku przeglądarki. ## Flow ```plantuml @startuml actor Front as F boundary Api as B F->B : User chce danych o np. Restauracji przez GraphQL B->B : Query Graphql deleguje pracę do modelu B->B : Model deleguje gettery niektórych, \ntłumaczonych atrybutów do adaptera translacji B->B : Adapter translacji wie w jakim języku user pyta \n i robi lookup odpowiednich translacji w tabeli Translation B->F : API zwraca zlokalizowane dane @enduml ``` ## Query Zwracamy teksty tylko/od razu w języku usera (lub z headerów) z fallbackiem na język z settingsów (domyślnie PL) ## Mutacje - admin Zapis tłumaczeń z panelu admina możemy zaimplementować na dwa sposoby w zależności jak edycja miałaby wyglądać na adminie. Dla przykładu użyty model `Tag` mający pole `name`: - mutacja create/updateTag przyjmuje array tłumaczeń: ``` mutation { updateTag( id: 1, name: [ { locale: PL, value: 'romantyczna'}, { locale: EN, value: 'romantic'}, ] ) } ``` - mutacja przyjmuje kontekst tłumaczeń ``` mutation { updateTag( id: 1, name: 'romantyczna', locale: PL ) } ``` ## Todosy 0. Określenie listy pól tłumaczonych dla każdego modelu 1. Stworzenie tabeli i migracja 2. Stworzenie generalnego adaptera do modeli AR (najtrudniejsze) 3. Stworzenie generalnego wpinalnego w queriesy i mutacje adaptera do GraphQL 4. Migracja w celu dodania defaultowych PL tłumaczeń (z tego co mamy) do określonych modeli 5. Wycięcie w pień redundantnych pól z modeli (wszystkie tłumaczone pola będą przemapowane do tabelki `Translations`) ``` rspec ./spec/models/submission_spec.rb:14 # Submission#incoming_changes when provided invalid incoming changes is expected not to be valid rspec ./spec/services/v1/restaurants/updaters/submission_spec.rb:28 # V1::Restaurants::Updaters::Submission#call adds proper changes to submission rspec ./spec/services/v1/restaurants/updaters/submission_spec.rb:20 # V1::Restaurants::Updaters::Submission#call does not update restaurant rspec ./spec/services/v1/restaurants/updaters/submission_spec.rb:73 # V1::Restaurants::Updaters::Submission#call with billing data when restaurant does not have billing data adds proper changes to submission rspec ./spec/services/v1/restaurants/updaters/submission_spec.rb:106 # V1::Restaurants::Updaters::Submission#call with billing data when restaurant has billing_data adds proper changes to submission rspec ./spec/services/v1/restaurants/updaters/submission_spec.rb:133 # V1::Restaurants::Updaters::Submission#call with tables with attributes adds proper changes to submission rspec ./spec/services/v1/restaurants/updaters/submission_spec.rb:177 # V1::Restaurants::Updaters::Submission#call with tables without attributes adds proper changes to submission rspec './spec/models/restaurant_spec.rb[1:1:25:1:1:1]' # Restaurant behaves like a model behaves like attribute_limiting text length validation for name with text longer than limit is invalid rspec ./spec/services/v1/submissions/changes_validator_spec.rb:33 # V1::Submissions::ChangesValidator#call when submissionable is restaurant when changes are invalid with submissionable has invalid submission ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully