Jump to content

Automatic translation with dictionary table


LoisLane
 Share

This topic is 2333 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies

In my FileMaker solution, I would like to automatically translate certain fields from my "Products" table into fields in my "Products_2" table using a dictionary stored in my "Dictionary" table.

I suppose I should somehow use the Substitute function, but how do I retrieve (all) the values from the "Dictionary" table?

Link to comment
Share on other sites

I don't think you need all the values from the "Dictionary" table. You only need the matching value, which you can get through a relationship.

However, I would question the setup you describe. Why would you have two Products tables? And what are these "certain fields" that need translation? I suspect the real problem is somewhere else.

 

Edited by comment
Link to comment
Share on other sites

  • Newbies

The fields that need translation are fields with a lot of text, like for example the "Description" field. Several words in that field will need to be translated, so there is more than just one matching value. I might be able to keep it all in one table, but for clarity I have separated my data into a danish table (Products) and a norwegian table (Products_2). This shouldn't affect the translation challenge, I suppose.

Link to comment
Share on other sites

3 hours ago, LoisLane said:

Several words in that field will need to be translated, so there is more than just one matching value.

I see. Well, you could use Substitute() in a recursive custom function - but you need to keep in mind that (a) the Substitute() function is case-sensitive, (b) it works with patterns, not words, and (c) cumulative application can have unexpected results (as each iteration works on the result of previous ones).

If these limitations do not affect you, try a custom function such as:

 MultiSubstitute ( text ; searchValues ; replaceValues ) =

Let ( [
countValues = ValueCount ( searchValues ) ;
searchString = GetValue ( searchValues ; 1 ) ;
replaceString = GetValue ( replaceValues ; 1 ) ;
result = Substitute ( text ; searchString ; replaceString )
] ;
Case (
countValues > 1 ; MultiSubstitute ( result ; RightValues ( searchValues ; countValues - 1 ) ;  MiddleValues ( replaceValues ; 2 ; countValues - 1 ) ) ;
result
)
)

To use the function, define a relationship to the Dictionary table using the x relational operator, then make your calculation =

MultiSubstitute ( YourField ; List ( Dictionary::SearchString ) ; List ( Dictionary::ReplaceString ) )

 

Alternatively consider a scripted approach using the Perform Find/Replace script step in a loop.

  • Like 1
Link to comment
Share on other sites

  • Newbies

So far, so good... but a new challenge has come up:

The records in the "Dictionary" table need to be inserted to the MultiSubstitute function in a certain order. Unfortunately, the sort order I have made in the "Dictionary" table is ignored which leads to errors. How do I solve this problem?

Link to comment
Share on other sites

  • 3 weeks later...

This topic is 2333 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.