Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include en-US description of custom roles in static API #1181

Merged
merged 2 commits into from
Jan 9, 2024

Conversation

dtolnay
Copy link
Member

@dtolnay dtolnay commented Jan 8, 2024

In #1154, the static-api data (v1/teams.json) included only ids of roles, such as "roles": ["spec-editor"]. Separately the public-facing descriptions for the roles would be included in a ftl translation file produced by dump-website.

governance-role-spec-editor = Editor

This worked!

Screenshot from 2024-01-08 12-25-08

but has the downside that if some new role is introduced into the team repo before the translation for it lands in rust-lang/www.rust-lang.org in locales/en-US/teams.ftl, then the website would temporarily display the following ugly placeholder, until a commit such as rust-lang/www.rust-lang.org#1821 syncs the ftl file.

Screenshot from 2024-01-08 13-17-28

There are 2 potential fixes:

  1. Hide role from the website if localization is not available. This means roles would be added in rust-lang/team without immediately showing up on the website. They would show up only after the next ftl sync, which happens only about once a year.

  2. Include an en-US description in static-api. As soon as a role appears in rust-lang/team, it will appear on the website with a fallback to the English description from teams.json.

Approach 2 is what the website already does for team names and descriptions. See the logic here: https://github.com/rust-lang/www.rust-lang.org/blob/b35215187ed75d4d2a9a056f1847309aa2d404d2/src/i18n.rs#L151-L169

Pseudocode:

if lang == "en-US" {
    write(team.website_data.description)
} else if let Some(localized) = fluent::get("governance-team-" + team.name + "-description") {
    write(localized)
} else {
    write(team.website_data.description)
}

This PR makes it possible to do approach 2 for roles too.

{
  "name": "spec",
  "members": [
    ...
    {
      "name": "Joel Marcey",
      "github": "JoelMarcey",
      "roles": [
        "spec-editor"
      ]
    }
  ],
  "website_data": {
    "name": "Specification team",
    "description": "Creating and maintaining the specification for the Rust language",
    "page": "spec",
    ...
  },
  "roles": [
    {
      "id": "spec-editor",
      "description": "Editor"
    }
  ]
}

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

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

This seems reasonable to me!

@rylev rylev merged commit 4fea82a into rust-lang:master Jan 9, 2024
1 check passed
@dtolnay dtolnay deleted the websiteroles branch January 9, 2024 14:32
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.

None yet

2 participants