Bug 1047215 - [Gallery/Video]Background Overlays are not translated

This PR incorporates the patch from bug 1038984 as those changes to dialogs.js are required for this patch.
These three conditions are mutually exclusive. May we use a if-else if-else to wrap them? Like:
```
iif (options[prefix + 'Id']) {
...
} else if (options[prefix] || options[prefix + 'Text']) {
  var textOption = options[prefix] || options[prefix + 'Text'];
...
} else if (defaultId) {
...
}
```