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

Option to change strings #406

Closed
adriankwiat opened this issue Aug 25, 2019 · 4 comments · Fixed by #504
Closed

Option to change strings #406

adriankwiat opened this issue Aug 25, 2019 · 4 comments · Fixed by #504

Comments

@adriankwiat
Copy link
Member

adriankwiat commented Aug 25, 2019

We are preparing to participate in Google Code-in, and have reserved this issue for participants in GCI - but we'd love to have your help with another one! Please check out https://code.publiclab.org to see more

Please describe the desired behavior.
Describe the solution you'd like.

I'm making an app in another language and I want to change default strings (tooltips, confirms, etc).

Additional context (optional)
Feel free to include any applicable: code, screenshots, or gifs.

For example:

let img = L.distortableImageOverlay('image.jpg', {
  // options
  strings: {
    delete: 'Usuń',
    confirmDelete: 'Czy na pewno chcesz usunąć obraz?',
    lock: 'Zablokuj',
    unlock: 'Odblokuj',
    rotate: 'Obróć',
    // ...
  }
});
@sashadev-sky
Copy link
Member

Hi! Thank you for the feature request. We are in the process of revamping our actions API to make each action customizable without have to overwrite the whole thing. This will probably be done in the next few weeks or so.

In the meantime, you can achieve your desired results by rewriting the actions as custom actions. This is not well documented in the README currently because there will be updates -

To create a custom action, just extend L.EditAction.

Here is an example of one we overrwrote downstream (this is done for the collection group, but L.distortableImageOverlay takes the same actions option.

 var customDeletes = mapknitter.customDeletesAction();
 var imgGroup = L.distortableCollection({
     actions: [customExports]
  }).addTo(map);

 /** The upstream delete action also triggers a confirmation window, this one won't */
  customDeleteAction: function () {
    var action = L.EditAction.extend({
      initialize: function (map, overlay, options) {
        var use = 'delete_forever';
        options = options || {};
        options.toolbarIcon = {
          svg: true,
          html: use,
          tooltip: 'Delete Image'
        };

        L.EditAction.prototype.initialize.call(this, map, overlay, options);
      },

      addHooks: function () {
        this._overlay.fire('delete');
      }
   });

   return action;
}

It is not ideal, because you would have to recreate every action, but it is the way you would do this before we expand our API for it.

Let me know if you have any more questions!

@rexagod
Copy link
Member

rexagod commented Dec 1, 2019

Uploaded to GCI dashboard.

@SidharthBansal
Copy link
Member

Please read through the guidelines of gci tasks creation. You are missing scores, code links and adding it to the tasklist.
Thanks

@SidharthBansal
Copy link
Member

Similarly for other issues/tasks

jywarren pushed a commit that referenced this issue Jan 2, 2020
* ADD: Custom translations functionality

We are getting closer to the stable API and one of the important features
is to allow developers to translate LDI in their native language.
This commit implements the requested feature.

Resolves #406

* ADD: Documentation for custom translations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants