Skip to content

Frontend tweaks2 #2

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

Open
wants to merge 5 commits into
base: bugfix/crash-when-no-key
Choose a base branch
from
Open

Conversation

distinctdan
Copy link

No description provided.

Daniel Stone added 2 commits September 28, 2017 17:31
 - Making it run on js files
 - Making it not autoinsert angular brackets
@@ -77,7 +77,7 @@ module Generators =
let private deTag (t : LocalizationSourcePart) : string =
match t with
| Text s -> s
| Variable s -> "{{" + s + "}}"
| Variable s -> s

Copy link

@JamesFaix JamesFaix Oct 8, 2017

Choose a reason for hiding this comment

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

If in both cases we return the input, this function isn't really doing anything.

In C# this function would be kinda like:

enum LocalizationSourcePartType { Text, Variable }

string deTag(LocalizationSourcePart t)
{
    if (t.LocalizationSourcePartType == LocalizationSourcePartType.Text) {
        var s = (string)t;
        return s;
    }
    if (t.LocalizationSourcePartType == LocalizationSourcePartType.Variable)
    {
        var s = (string)t;
        return s;
    }
    
    throw new Exception("This can never be hit because of the enum values");
}

Copy link
Author

Choose a reason for hiding this comment

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

So, it still does map a LocalizationSourcePart to either its Text or Variable property. Is there a more elegant way to do that?

Choose a reason for hiding this comment

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

@distinctdan The more I look at it, I think this function is actually required to appease the compiler's type checker. Even thought a LocalizationSourcePart is effectively a string, you still need a mapping function to String. The name deTag isn't really appropriate though.

Choose a reason for hiding this comment

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

I would just call is asString or stringify or something (because ToString is already a default method in .NET which will return the type name here I believe.

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, I'd agree. I'm thinking I'll leave it alone for now since we're wanting to make some significant revisions to the compiler anyways in the future as well.

@@ -17,11 +17,12 @@ module Program =
open Ids.Localization.Parsers
open Ids.Localization.Parsers.XliffGenerator.XliffGenerator

let supportedFileTypes = new System.Text.RegularExpressions.Regex("htm|html|js")

Choose a reason for hiding this comment

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

Consider adding open System.Text.RegularExpfessions a few lines up to avoid inline namespaces.

Copy link
Author

Choose a reason for hiding this comment

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

Will do

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.

2 participants