Skip to content

fixed the issue when the Share roles show a wrong translation after t…#11241

Merged
2403905 merged 1 commit intoowncloud:masterfrom
2403905:issue-11025
Apr 17, 2025
Merged

fixed the issue when the Share roles show a wrong translation after t…#11241
2403905 merged 1 commit intoowncloud:masterfrom
2403905:issue-11025

Conversation

@2403905
Copy link
Contributor

@2403905 2403905 commented Apr 16, 2025

…he user location has changed back to English

Description

Fixed the issue when the Share roles show a wrong translation after the user location has changed back to English

Related Issue

Motivation and Context

How Has This Been Tested?

  • test environment:
  • test case 1:
  • test case 2:
  • ...

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@2403905 2403905 requested a review from kobergj April 16, 2025 18:57
Copy link
Contributor

@LukasHirt LukasHirt left a comment

Choose a reason for hiding this comment

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

This does not solve the issue unfortunately. The problem is not that it would not get translated back to EN but that the role translatable strings seem to be overwritten with the translated strings. The issue is then not only going back to EN but also switching e.g. EN -> DE -> ES.

You can see the broken behaviour even with these changes here:

Zaznam.obrazovky.2025-04-16.v.21.21.58.mov

What fixes the issue for me is using deepcopy like this:

deepcopy.Copy(conversions.ToValueSlice(
    unifiedrole.GetRolesByPermissions(
        unifiedrole.GetRoles(unifiedrole.RoleFilterIDs(s.config.UnifiedRoles.AvailableRoles...)),
        allowedActions,
        condition,
        listFederatedRoles,
        false,
    ),
)).([]libregraph.UnifiedRoleDefinition)
Zaznam.obrazovky.2025-04-16.v.21.27.34.mov

This way source strings are not overwritten and translated strings are always returned in the correct locale.

@LukasHirt
Copy link
Contributor

LukasHirt commented Apr 16, 2025

The problem is not that it would not get translated back to EN but that the role translatable strings seem to be overwritten with the translated strings.

When running oCIS with debugger and roles are translated once, they would then always be in that locale returned already here:

return filterRoles(buildInRoles, f)

That is why I came to the conclusion that the translatable source string is overwritten with a "static" string. Also, description of this method makes it sound like it:

f.SetString(val)

SetString sets v's underlying value to x.

@LukasHirt
Copy link
Contributor

One more test hinting at overwritten translatable strings - #11025 (comment)

…he user location has changed back to English
@sonarqubecloud
Copy link

@2403905
Copy link
Contributor Author

2403905 commented Apr 16, 2025

UPD #11025 (comment)

@2403905 2403905 requested a review from LukasHirt April 17, 2025 07:22
Copy link
Contributor

@LukasHirt LukasHirt left a comment

Choose a reason for hiding this comment

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

Awesome @2403905, issue is gone now! Leaving the approval to someone more skilled in Go though to better review the code :D

@2403905 2403905 enabled auto-merge April 17, 2025 09:49
@2403905 2403905 requested a review from mklos-kw April 17, 2025 10:05
}

// buildInRoles contains the built-in roles.
func buildInRoles() []*libregraph.UnifiedRoleDefinition {
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly: The fix is to evaluate roles with localized descriptions at point when proper l10n context is available?

@2403905 2403905 merged commit ceeca12 into owncloud:master Apr 17, 2025
4 checks passed
ownclouders pushed a commit that referenced this pull request Apr 17, 2025
fixed the issue when the Share roles show a wrong translation after t…
@PrajwolAmatya PrajwolAmatya mentioned this pull request Jun 10, 2025
78 tasks
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.

Share roles returned in a wrong locale

3 participants