Repository: mozilla/pontoon

Issue:
Set direction on placeables
*This issue was created automatically by a [script](https://github.com/mathjazz/bugzilla2github/).*
## [Bug 1692620](https://bugzilla.mozilla.org/show_bug.cgi?id=1692620)
Bug Reporter: @mathjazz

Created attachment 9202997
Screenshot

Everywhere we mark up placeables (i.e. everywhere we show strings in the translate view except in the textarea), we need to set the `dir` attribute to `ltr` in order to prevent bad display of placeables in RTL strings (as seen on the screenshot).
Pontoon picks the wrong folder format for locales (underscore instead of hyphens)
*This issue was created automatically by a [script](https://github.com/mathjazz/bugzilla2github/).*
## [Bug 1698636](https://bugzilla.mozilla.org/show_bug.cgi?id=1698636)
Bug Reporter: @flodolo
CC:   @mathjazz

I created the repository with the source in `en-US` folder.
https://github.com/mozilla-l10n/mozilla-vpn-website-l10n/

Pontoon then synced `pt-BR` as `pt_BR`. One possible explanation is the presence of a file with underscores (`CODE_OF_CONDUCT.md`) in the repository. If that's the case, it's a bug, because we really care about folders, not files.

I then renamed `pt_BR` to use hyphens, synced translations for `en-CA` and it still used the wrong format (`en_CA`). Fixed this one too, synced a string for `en-GB`,  and again wrong format.

At this point, I don't know if it will keep using _ for the next locales.


Discussion:
Could I have this assigned to me? 
Done :)


Resolving patch:
diff --git a/pontoon/sync/utils.py b/pontoon/sync/utils.py
--- a/pontoon/sync/utils.py
+++ b/pontoon/sync/utils.py
@@ -48,10 +48,16 @@ def get_parent_directory(path):
 
 def uses_undercore_as_separator(directory):
     """
-    Return True if any subdirectory contains underscore.
+    Return True if the names of folders in a directory contain more '_' than '-'.
     """
+    only_folders = []
     subdirs = os.listdir(directory)
-    return "".join(subdirs).count("_") > "".join(subdirs).count("-")
+
+    for i in subdirs:
+        if os.path.isdir(os.path.join(directory, i)):
+            only_folders.append(i)
+
+    return "".join(only_folders).count("_") > "".join(only_folders).count("-")
 
 
 def directory_contains_resources(directory_path, source_only=False):


Test patch:
diff --git a/pontoon/sync/tests/__init__.py b/pontoon/sync/tests/__init__.py
--- a/pontoon/sync/tests/__init__.py
+++ b/pontoon/sync/tests/__init__.py
@@ -27,6 +27,10 @@
     os.path.dirname(__file__),
     "project-config-checkout",
 )
+LOCALE_SEPARATOR_TEST_PATH = os.path.join(
+    os.path.dirname(__file__),
+    "locale-separator-tests",
+)
 
 
 class VCSEntityFactory(factory.Factory):
diff --git a/pontoon/sync/tests/locale-separator-tests/another_file.py b/pontoon/sync/tests/locale-separator-tests/another_file.py
new file mode 100644
diff --git a/pontoon/sync/tests/locale-separator-tests/en_GB/.gitignore b/pontoon/sync/tests/locale-separator-tests/en_GB/.gitignore
new file mode 100644
diff --git a/pontoon/sync/tests/locale-separator-tests/en_NZ/.gitignore b/pontoon/sync/tests/locale-separator-tests/en_NZ/.gitignore
new file mode 100644
diff --git a/pontoon/sync/tests/locale-separator-tests/en_US/.gitignore b/pontoon/sync/tests/locale-separator-tests/en_US/.gitignore
new file mode 100644
diff --git a/pontoon/sync/tests/locale-separator-tests/es-ES/.gitignore b/pontoon/sync/tests/locale-separator-tests/es-ES/.gitignore
new file mode 100644
diff --git a/pontoon/sync/tests/locale-separator-tests/es-MX/.gitignore b/pontoon/sync/tests/locale-separator-tests/es-MX/.gitignore
new file mode 100644
diff --git a/pontoon/sync/tests/locale-separator-tests/some-file.py b/pontoon/sync/tests/locale-separator-tests/some-file.py
new file mode 100644
diff --git a/pontoon/sync/tests/test_utils.py b/pontoon/sync/tests/test_utils.py
new file mode 100644
--- /dev/null
+++ b/pontoon/sync/tests/test_utils.py
@@ -0,0 +1,6 @@
+from pontoon.sync.utils import uses_undercore_as_separator
+from pontoon.sync.tests import LOCALE_SEPARATOR_TEST_PATH
+
+
+def test_uses_undercore_as_separator():
+    assert (uses_undercore_as_separator(LOCALE_SEPARATOR_TEST_PATH)) is True