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

Can't save strings #359

Closed
Tracked by #888 ...
Nancy-Salpepi opened this issue Jan 23, 2023 · 13 comments
Closed
Tracked by #888 ...

Can't save strings #359

Nancy-Salpepi opened this issue Jan 23, 2023 · 13 comments

Comments

@Nancy-Salpepi
Copy link

Test device
MacBook Air (m1 chip)

Operating System
13.1

Browser
safari 16.2

Problem description
For phetsims/qa#878, translations are not saving even though the "Translation Saved" message appears on the screen.

Steps to reproduce
Here is an example:

  1. Select Faroese
  2. Select Diffusion
  3. Change some strings and press Save
  4. Press "Back to Faroese Sim List"
  5. Select Diffusion again -- boxes are blank
@Nancy-Salpepi
Copy link
Author

This seems to be an issue with Shared Strings and Common Strings.
It looks like Sim-Specific Strings are saving.

@liammulh
Copy link
Member

That is super helpful! Thanks!

@liammulh
Copy link
Member

I suppose the first place to look is the client-side saveTranslation.js module. I should log the translation to ensure it contains shared and common strings.

@liammulh liammulh changed the title Translations fail to save Can't save shared or common strings Jan 24, 2023
@liammulh
Copy link
Member

liammulh commented Jan 24, 2023

I am not able to reproduce locally with a config that is probably different from what's on Ox-Dev. I will try to reproduce on Ox-Dev.

@liammulh
Copy link
Member

liammulh commented Jan 24, 2023

This seems to be an issue with Shared Strings and Common Strings.
It looks like Sim-Specific Strings are saving.

I just tried to reproduce on Ox-Dev, and I am seeing that sim-specific strings are also not saving.

Specifically, I tried saving the value of Diffusion for diffusion.title. It seems to be in the database, but it's not showing when I go back to the translation form:

Screen Shot 2023-01-23 at 9 59 39 PM

rosetta> db.shortTermTranslationStorage.find({"locale": "fo"})
[
  {
    _id: ObjectId("63cf63c9a55beaf5bbb40502"),
    userId: '464468',
    timestamp: 1674535881340,
    simName: 'diffusion',
    locale: 'fo',
    translationFormData: {
      simIsPrototype: false,
      simSpecific: {
        diffusion_DOT_title: { english: 'Diffusion', translated: 'Diffusion' }
      },

@liammulh
Copy link
Member

The next step is to log the translation form data we get back from the server to verify the saved translation isn't being retrieved from the database. If it isn't we need to figure out why.

@Nancy-Salpepi
Copy link
Author

I went back today and tried again--sim specific strings aren't saving. I must have seen my changes in the form because I had pressed publish. Sorry!

@liammulh
Copy link
Member

I checked, and the translation form data I'm getting back from the server-side code has:

    "simSpecific": {
        "diffusion_DOT_title": {
            "english": "Diffusion",
            "translated": "Monday"
        }
    },

But in the database:

      simSpecific: {
        diffusion_DOT_title: { english: 'Diffusion', translated: 'Diffusion' }
      },

Next place to look (and probably log/debug) would be getTranslationFormData.js.

@liammulh
Copy link
Member

Okay, here's an idea: What if local check-login data is different from Ox-Dev check-login data? That might explain why I'm not seeing this issue locally, and the filer (see below) might be wrong on Ox-Dev.

      // Try to get saved translation in short-term storage database.
      const filter = {
        userId: userId.toString(), // The user ID should be a string since it's a string we get from website user data.
        simName: simName,
        locale: locale
      };
      const savedTranslation = await shortTermStringStorageCollection.findOne( filter );

@liammulh
Copy link
Member

Okay, here's an idea: What if local check-login data is different from Ox-Dev check-login data? That might explain why I'm not seeing this issue locally, and the filer (see below) might be wrong on Ox-Dev.

I don't think this is the case. I hit the check-login route, and my user ID was a string. Next step is to log the filter then try to use the filter to find the saved translation.

@liammulh
Copy link
Member

Oh, this is very sad:

Jan 25 11:39:21 phet-server-dev.int.colorado.edu rosetta[55642]: ----------> filter = {
Jan 25 11:39:21 phet-server-dev.int.colorado.edu rosetta[55642]: "userId": "654321",
Jan 25 11:39:21 phet-server-dev.int.colorado.edu rosetta[55642]: "simName": "diffusion",
Jan 25 11:39:21 phet-server-dev.int.colorado.edu rosetta[55642]: "locale": "fo"
Jan 25 11:39:21 phet-server-dev.int.colorado.edu rosetta[55642]: }

654321 is from the mock website user data.

Indeed, the environment config key is set to development:

Jan 25 11:36:11 phet-server-dev.int.colorado.edu rosetta[55642]: info: rosetta started
Jan 25 11:36:11 phet-server-dev.int.colorado.edu rosetta[55642]: info: http://localhost:16372/translate
Jan 25 11:36:11 phet-server-dev.int.colorado.edu rosetta[55642]: info: see config below
[...]
Jan 25 11:36:11 phet-server-dev.int.colorado.edu rosetta[55642]: info:     ENVIRONMENT: development

Mystery solved, I think. I will set it to production and try to reproduce the problem.

@liammulh
Copy link
Member

I switched the environment config key to production:

Jan 25 11:44:47 phet-server-dev.int.colorado.edu rosetta[56853]: info: rosetta started
Jan 25 11:44:47 phet-server-dev.int.colorado.edu rosetta[56853]: info: http://localhost:16372/translate
Jan 25 11:44:47 phet-server-dev.int.colorado.edu rosetta[56853]: info: see config below
[...]
Jan 25 11:44:47 phet-server-dev.int.colorado.edu rosetta[56853]: info:     ENVIRONMENT: production

And now I'm seeing the saved translation showing up:

Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: info: getting translation form data
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: info: checking for saved translation
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: ----------> filter = {
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: "userId": "464468",
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: "simName": "diffusion",
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: "locale": "fo"
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: }
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: info: found saved translation; returning it
Jan 25 11:44:59 phet-server-dev.int.colorado.edu rosetta[56853]: info: responding with fo/diffusion's translation form data

@liammulh liammulh changed the title Can't save shared or common strings Can't save strings Jan 25, 2023
@Nancy-Salpepi
Copy link
Author

This looks good in round 3. Will reopen if something else comes up.

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

No branches or pull requests

2 participants